Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ComboBox value rather than text is displayed when an option is selected

Tags:

wix

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.

How the drop down looks before and after selection.

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.

like image 739
Nanhydrin Avatar asked Dec 14 '15 13:12

Nanhydrin


People also ask

What method should you use to get the value of a combo box?

You can get selected value by using combobox1. SelectedValue and convert it to int and pass it to method.

What is the difference between ComboBox and drop-down list content control?

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.

What is combo box selection?

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.


1 Answers

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:

Drop down rendering with ComboList set to yes

Compared with the original:

Drop down rendering with no ComboList setting

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.

like image 79
Nanhydrin Avatar answered Sep 28 '22 03:09

Nanhydrin