Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using Windows Installer XML (WiX) Toolset version 3.10.2. When I create a ComboBox with items that have similar text, selection through the UI does not work as expected. As an example, I created the following list:

Value | Text
1 | TEXT 10000
2 | TEXT 5000
3 | TEXT 2000
4 | TEXT 1000
5 | TEXT 500
6 | TEXT 100

Selecting values 1, 2, and 3 works as expected. Selecting values 4 and 6 displays the text of value 1. Selecting value 5 displays the text of value 2.

I noticed that setting Sorted="no" does not have this odd behavior. However, that is not an option for my project.

What am I missing?

Someone filed issue #4069 with the WiX team. It was closed as unrelated to WiX; this behavior is controlled by MSI and/or Windows. However, there was no further recommendations for resolution.

What I have tried:

XML
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
	<Product Id="*" Name="WiX_ComboBox" Language="1033" Version="1.0.0.0" Manufacturer="Example Company" UpgradeCode="c45d2b80-fc84-48a2-a29c-46e781d26461">
		<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

		<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
		<MediaTemplate />

		<UIRef Id="WixUI_Common"/>
    <UIRef Id="CustomUi"/>
    <UIRef Id="WixUI_ErrorProgressText"/>

    <Property Id="BADCMBVAL1" Value="1" />
	</Product>

  <Fragment>
    <UI>
      <Dialog Id="BadComboBoxDlg" Width="370" Height="270" Title="Bad Combo Box" NoMinimize="yes">
        <Control Id="BadComboBox1" Type="ComboBox" X="100" Y="186" Width="100" Height="16" ComboList="yes" Sorted="yes" Property="BADCMBVAL1">
          <ComboBox Property="BADCMBVAL1">
            <ListItem Value="1" Text="TEXT 10000"/>
            <ListItem Value="2" Text="TEXT 5000"/>
            <ListItem Value="3" Text="TEXT 2000"/>
            <ListItem Value="4" Text="TEXT 1000"/>
            <ListItem Value="5" Text="TEXT 500"/>
            <ListItem Value="6" Text="TEXT 100"/>
          </ComboBox>
        </Control>

        <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" />
        <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
          <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
        </Control>
      </Dialog>
    </UI>
  </Fragment>

  <Fragment>
    <UI Id="CustomUi">
      <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
      <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
      <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />

      <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
      <Property Id="WixUI_Mode" Value="Mondo" />

      <DialogRef Id="ErrorDlg" />
      <DialogRef Id="FatalError" />
      <DialogRef Id="FilesInUse" />
      <DialogRef Id="MsiRMFilesInUse" />
      <DialogRef Id="PrepareDlg" />
      <DialogRef Id="ProgressDlg" />
      <DialogRef Id="ResumeDlg" />
      <DialogRef Id="UserExit" />


      <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>

      <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="BadComboBoxDlg">1</Publish>

      <Publish Dialog="BadComboBoxDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
      <Publish Dialog="BadComboBoxDlg" Control="Next" Event="SpawnDialog" Value="CancelDlg">1</Publish>
    </UI>
  </Fragment>
</Wix>
Posted
Updated 17-Oct-16 15:29pm
v9

1 solution

It appears that MSI has problems performing string comparisons on ComboBox text of different lengths. So, a work-around is to alter the text to have the same lengths. By padding the ends of each text field, the desired appearance is maintained:

XML
<Control Id="BadComboBox1" Type="ComboBox" X="100" Y="186" Width="100" Height="16" ComboList="yes" Sorted="yes" Property="BADCMBVAL1">
  <ComboBox Property="BADCMBVAL1">
    <ListItem Value="1" Text="TEXT 10000"/>
    <ListItem Value="2" Text="TEXT 5000 "/>
    <ListItem Value="3" Text="TEXT 2000 "/>
    <ListItem Value="4" Text="TEXT 1000 "/>
    <ListItem Value="5" Text="TEXT 500  "/>
    <ListItem Value="6" Text="TEXT 100  "/>
  </ComboBox>
</Control>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900