0

I am trying to populate values using custom actions and want to bind the values into combobox which is inside product.wxs.

Can anyone guide me how to bind values if I want to populate a list of countries inside the combobox?

I am struggling with how to pass this value so the values will show inside combox while executing my MSI setup.

Below provide the code which I am trying:

    public static ActionResult FillList(Session xiSession)
    {

        Dictionary<string, string> _co = new Dictionary<string, string>();
        _co.Add(String.Empty, String.Empty);
        _co.Add("US", "United States");
        _co.Add("CA", "Canada");
        _co.Add("MX", "Mexico");

        xiSession.Log("Return success");
        return ActionResult.Success;
    }

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

    <Feature Id="ProductFeature" Title="SetupProjectComboTest" Level="1">
        <ComponentGroupRef Id="ProductComponents" />
    </Feature>

<UI>
  <UIRef Id="WixUI_Mondo" />

  <Dialog Id="MyCustomDlg"  Width="500" Height="260">
    <Control Id="ComboBoxMain" Type="ComboBox" X="10" Y="60" Width="300" Height="17" Property="COUNTRIES" />
    <Control Id="ButtonMain" Type="PushButton" X="320" Y="60" Width="40" Height="17" Text="Show">
      <Publish Property="COMBOVALUEFORMATTED" Order="1"  Value="[COUNTRIES]" />
    </Control>
    <Control Id="LabelMain" Type="Text" X="10" Y="80" Width="360" Height="17" Property="COMBOVALUEFORMATTED" Text="[COMBOVALUEFORMATTED]" />

  </Dialog>
</UI>

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" Name="SetupProjectComboTest" />
        </Directory>
    </Directory>
</Fragment>

<Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
        <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
        <!-- <Component Id="ProductComponent"> -->
            <!-- TODO: Insert files, registry keys, and other resources here. -->
        <!-- </Component> -->
    </ComponentGroup>
</Fragment>

4

1 回答 1

2

您需要在ComboBox 表中插入行以绑定 List 值。如果您在ORCA Editor中打开 msi ,您可以找到 msi 表和行。

如果您在 msi 中不使用任何其他 ComboBox 元素,则应包含EnsureTable元素。

  <EnsureTable Id="ComboBox"/>

您可以从自定义操作插入行。

  static int index = 1;
 public static void FillComboBox(Session session, string text, string value)
    {
        View view = session.Database.OpenView("SELECT * FROM ComboBox");
        view.Execute();

        Record record = session.Database.CreateRecord(4);
        record.SetString(1, "COUNTRIES");
        record.SetInteger(2, index);
        record.SetString(3, value);
        record.SetString(4, text);

        view.Modify(ViewModifyMode.InsertTemporary, record);
        view.Close();
        index++;
    }

在自定义操作中调用该FillComboBox方法。

   public static ActionResult FillList(Session xiSession)
    {

        FillComboBox(xiSession, "US", "United States");
        FillComboBox(xiSession, "CA", "Canada");
        FillComboBox(xiSession, "MX", "Mexico");          

        return ActionResult.Success;
    }

在运行该组合框对话框之前执行InstallUIsequence中的自定义操作。

   <InstallUISequence>
     <Custom Action="INSERT_ROWS" After="AppSearch">Not Installed</Custom>
  </InstallUISequence>
于 2013-06-14T09:32:15.307 回答