Nanhydrin
Nanhydrin

Reputation: 4472

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

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.

Upvotes: 5

Views: 1363

Answers (2)

Nanhydrin
Nanhydrin

Reputation: 4472

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.

Upvotes: 8

Arkady Sitnitsky
Arkady Sitnitsky

Reputation: 1886

You can see here http://wixtoolset.org/documentation/manual/v3/xsd/wix/listitem.html that the text attribute is for localization purpose and if not used it will be the value of the value attribute.

"The localizable, visible text to be assigned to the item. If not specified, this will default to the value of the Value attribute."

I suggest to use only value attribute and remove text attribute.

Upvotes: -1

Related Questions