I have a custom Wix dialog and on that dialog is a ComboBox control.
The ComboBox setup being used to create the dialog is as follows:
<Control Type="ComboBox" Id="OptionType" Width="150" Height="13" X="41" Y="68" Property="SELECTEDOPTION">
<ComboBox Property="SELECTEDOPTION">
<ListItem Text="None" Value="None" />
<ListItem Text="Option 1" Value="Option_1"/>
<ListItem Text="Option 2" Value="Option_2"/>
<ListItem Text="Option 3" Value="Option_3"/>
</ComboBox>
</Control>
When the ComboBox is displayed during the install, I can see the correct text in the drop down list, e.g. "Option 2", but when I select that item and the drop down collapses and the selected option is put in the visible field I'm seeing "Option_2" displayed, i.e. the text being displayed is the from the Value attribute, not the Text attribute. The below screenshot should clarify what I'm talking about.
Clearly I'm missing something in my control setup, is ComboBox the wrong tool for this job, or is there a property on the Control or ComboBox that I should be setting?
I've looked at the Wix documentation but nothing is jumping out at me.
You can get selected value by using combobox1. SelectedValue and convert it to int and pass it to method.
A drop-down list is a list in which the selected item is always visible, and the others are visible on demand by clicking a drop-down button. A combo box is a combination of a standard list box or a drop-down list and an editable text box, thus allowing users to enter a value that isn't in the list.
The Windows Forms ComboBox (SfComboBox) allows you to select single or multiple items in the drop-down list. The selection mode can be set by using the ComboBoxMode property. Combo box has two different modes: SingleSelection: Selects single item. MultiSelection: Selects multiple items.
I've found a solution.
Going back to the Wix documentation for the Control element, I came across an attribute called ComboList for which there is no description. So I thought I'd give it a try and see what happened.
This is what I got:
Compared with the original:
So it's changed the drop down from one you can type in, to a regular one.
And with that it's also given me what I need - now when I select "Option 2", I get "Option 2".
It still works fine with retrieving previous values for the SELECTEDOPTION setting from the registry as well, because of course the value of each item in the list has not changed.
All I did was add the ComboList="yes" attribute to the Control element which gave me:
<Control Type="ComboBox" Id="OptionType" Width="150" Height="13" X="41" Y="68" Property="SELECTEDOPTION" ComboList="yes" Sorted="yes">
Unrelated to the original question, but possibly useful for anyone who ends up looking at this - I also added the Sorted="yes" attribute, because that then sorted the drop down list elements in the order I added them to the list. If you leave it out then it sorts the items alphabetically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With