我最近为我的 C# .NET Windows 窗体应用程序创建了一个安装项目。
在我的用户界面编辑器中我有:
- Start
- Welcome
- Textboxes (A)
- Installation Folder
- Confirm Installation
在文本框 (A) 对话框中,我有一个我想强制设置的编辑字段。
我该怎么做?我已经下载了 Orca 编辑器。有没有一种简单的方法可以使用它来做到这一点?
这是我希望实现的两个目标(至少是目标 1):
- 根据编辑标签非空启用/禁用下一步按钮
- 是否可以在点击下一步按钮后验证内容?
感谢任何帮助。
谢谢!
最佳答案
Windows Installer 对话框定义位于 VS 已部署版本的 IDE 文件夹下的 CommonExtensions\Microsoft\VSI\bin\VsdDialogs
文件夹中,例如,对于 VS 2017,它是这样的:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\VSI\bin\VsdDialogs\
在该文件夹中,转到 0
和 1033
文件夹,运行 orca
以管理员身份更改 VsdCustomText1Dlg.wid
文件,该文件用于 Textboxes (A)
。
Note 1: You can create a new windows installer dialog by copying that file and renaming it to
MyCustomDialog.wid
. Then open it in orca and go toModuleDialog
table and change theDisplayName
toMy Custom Dialog
. Make sure you copy the file in both1033
and0
. Then in VS, you can add an instance of this dialog using User Interface Editor of Setup project.
Note 2: You can also edit the
msi
file usingOrca
and edit the control conditions, but if you do so, then every time you build the setup project, you need to repeat editing of themsi
file. So editing.wid
makes more sense.
Note 3: Combining conditions of fields using
AND
andOR
is possible as well. For more information, take a look at ControlCondition Table and Conditional Statement Syntax
在 Windows Installer 自定义对话框中强制设置一个字段
要使 Edit1
值成为必需值并启用或禁用 Next 按钮:
以管理员身份运行
orca
打开用于添加自定义对话框的
wid
文件。在
ControlCondition
中,除了现有行之外,添加以下行:┌──────────────┬──────────────┬──────────────┬──────────────┐ │ Dialog_ │ Control_ │ Action │ Condition │ ├──────────────┼──────────────┼──────────────┼──────────────┤ ... │ CustomTextA │ NextButton │ Disable │ EDITA1="" │ │ CustomTextA │ NextButton │ Enable │ EDITA1<>"" │ └──────────────┴──────────────┴──────────────┴──────────────┘
保存文件并确保
1033
和0
文件夹中有相同的文件。关闭
Orca
重建安装项目。
安装它。
结果你会看到这样的行为:
关于c# - 如何在 Windows Installer 自定义对话框中将字段设置为必填,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59437532/