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.
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.
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
精彩评论