0

カスタム アクションを使用して値を入力しようとしていますが、その値を product.wxs 内のコンボ ボックスにバインドしたいと考えています。

コンボボックス内に国のリストを入力したい場合、値をバインドする方法を教えてもらえますか?

この値を渡す方法に苦労しているため、MSI セットアップの実行中にコンボックス内に値が表示されます。

以下に、私が試しているコードを示します。

    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

List 値をバインドするには、ComboBox テーブルに行を挿入する必要があります。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++;
    }

Custom アクション内で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 に答える