dommer
dommer

Reputation: 19810

How do I set the selected item in an MSI combo box that has been filled from a custom action?

I'm creating an web site MSI using WiX. I have a custom action (written in C#) that fills a combo box with the descriptions of the web sites in IIS so the user can select an existing web site to install to.

Works fine - apart from the fact that there's no item selected when the dialog page is first shown. I'd like the first site in the list to be selected by default.

Any idea how I might do this? None of the "obvious" (to me) things seem to work.

I'm using the latest version of WiX.

Upvotes: 1

Views: 2051

Answers (2)

Pavel K
Pavel K

Reputation: 3618

There is actually a possibility to preselect exact value for a combobox - just set the property, which is connected to the combobox, in your Custom Action's code to the desired value and it will get preselected in the UI.

For example, if you have a combobox

 <Control Id="WebSiteCombobox" Type="ComboBox" Property="IIS_WEBSITE_ID" Width="320" Height="16" X="20" Y="80" ComboList="yes" Sorted="yes"/>

then, in you custom action's c# code:

foreach (Site site in iisSites)
{
    //code to fill the combobox
}

session["IIS_WEBSITE_ID"] = iisSites.First().Id.ToString(); //Or to any other value you want to be preselected

Upvotes: 0

Christopher Painter
Christopher Painter

Reputation: 55581

Each row has a value and the control has a property. The property will have the value of the selected row. There is no concept of control.value or control.selecteditem.value in this language.

Upvotes: 2

Related Questions