Ashish Rana
Ashish Rana

Reputation: 127

Populating ListBox in wix installer

I have created a ListBox in my wix project and i want to populate that ListBox with values coming from the custom action. What i want is that on click of a button my custom action should get called and further my ListBox should get populated. I don't know what is going wrong. So, if anyone knows how to do it, please help. Thanx in advance.

Code in My Custom Action:-

Database db = session.Database;
string var = db.Tables["ListBox"].SqlInsertString + "TEMPORARY";
Microsoft.Deployment.WindowsInstaller.View var2 = db.OpenView(var);
var2.Execute(new Record(new object[] {"PROPERTY NAME", 5, "5", "value"}));
var2.Close();

Code in Wix project:-

<Control Id="ANY ID" Property="PROPERTY NAME" Type="ListBox" X="20" Y="20" Width="300" Height="300" Sorted="yes">
<ListBox Property="PROPERTY NAME">
    <ListItem Text="[PROPERTY NAME]" Value="[PROPERTY NAME]"/>
</ListBox>
</Control>

Code on Button for Calling Custom Action and refreshing value of property that is set on ListBox:-

<Control Id="ANY ID" Type="PushButton" Text="[Next]" Height="200" Width="200" X="160" Y="160" Bitmap="yes" FixedSize="yes" Default="yes">
<Publish Event="DoAction" Value="CustomAction">1</Publish>
<Publish Property="PROPERTY NAME" Value="[PROPERTY NAME]" Order="2">2</Publish>
</Control>

After all this, I am not able to see the value that is being inserted to the table in CustomAction or in other words, the ListBox is not getting populated after doing all this.

Upvotes: 2

Views: 1322

Answers (1)

Ashish Rana
Ashish Rana

Reputation: 127

It will not work this way. We have to call the Custom Action On load of the next dialog. This works for me:-

<InstallUISequence>
<Custom Action="NAME_OF_CUSTOM_ACTION" Before="DIALOG_NAME_ON_WHICH_YOU_WANT_TO POPULATE_THE_LISTBOX"/>
<Show Dialog="DIALOG_NAME_ON_WHICH_YOU_WANT_TO POPULATE_THE_LISTBOX"
After="PREVIOUS_DIALOG_NAME"/>
</InstallUISequence> 

Upvotes: 2

Related Questions