如何在已通过自定义操作填充的 MSI 组合框中设置所选项目?

发布于 2024-09-19 04:48:40 字数 211 浏览 2 评论 0原文

我正在使用 WiX 创建一个网站 MSI。我有一个自定义操作(用 C# 编写),它用 IIS 中网站的描述填充组合框,以便用户可以选择要安装到的现有网站。

工作正常 - 除了第一次显示对话框页面时没有选择任何项目这一事实之外。我希望默认选择列表中的第一个站点。

知道我该怎么做吗? (对我来说)“显而易见”的事情似乎都不起作用。

我正在使用最新版本的 WiX。

I'm creating an web site MSI using WiX. I have a custom action (written in C#) that fills a combo box with the descriptions of the web sites in IIS so the user can select an existing web site to install to.

Works fine - apart from the fact that there's no item selected when the dialog page is first shown. I'd like the first site in the list to be selected by default.

Any idea how I might do this? None of the "obvious" (to me) things seem to work.

I'm using the latest version of WiX.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

森林很绿却致人迷途 2024-09-26 04:48:40

每行都有一个值,控件有一个属性。该属性将具有所选行的值。该语言中没有 control.value 或 control.selecteditem.value 的概念。

Each row has a value and the control has a property. The property will have the value of the selected row. There is no concept of control.value or control.selecteditem.value in this language.

踏雪无痕 2024-09-26 04:48:40

实际上可以为组合框预先选择精确的值 - 只需将自定义操作代码中连接到组合框的属性设置为所需的值,它将在 UI 中预先选择。

例如,如果您有一个组合框

 <Control Id="WebSiteCombobox" Type="ComboBox" Property="IIS_WEBSITE_ID" Width="320" Height="16" X="20" Y="80" ComboList="yes" Sorted="yes"/>

,则在自定义操作的 C# 代码中:

foreach (Site site in iisSites)
{
    //code to fill the combobox
}

session["IIS_WEBSITE_ID"] = iisSites.First().Id.ToString(); //Or to any other value you want to be preselected

There is actually a possibility to preselect exact value for a combobox - just set the property, which is connected to the combobox, in your Custom Action's code to the desired value and it will get preselected in the UI.

For example, if you have a combobox

 <Control Id="WebSiteCombobox" Type="ComboBox" Property="IIS_WEBSITE_ID" Width="320" Height="16" X="20" Y="80" ComboList="yes" Sorted="yes"/>

then, in you custom action's c# code:

foreach (Site site in iisSites)
{
    //code to fill the combobox
}

session["IIS_WEBSITE_ID"] = iisSites.First().Id.ToString(); //Or to any other value you want to be preselected
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文