OpenFileDialog.AutoUpgradeEnabled 在 Vista 或 7 下不起作用?
如果我指定 OpenFileDialog.AutoUpgradeEnabled = true,我的程序仍然显示旧的 XP 样式对话框。知道为什么会发生这种情况吗?这是我在 Main() 中启用主题之后的情况
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Primary());
}
,这是我的对话框代码:
private void OpenProgramFile()
{
OpenFileDialog programFileDialog = new OpenFileDialog();
programFileDialog.Filter = "Program files (*.exe;*.lnk)|*.exe|All files (*.*)|*.*";
programFileDialog.FilterIndex = 0;
programFileDialog.Title = "Select program file";
programFileDialog.AutoUpgradeEnabled = true;
programFileDialog.ShowHelp = true;
DialogResult fileResult = programFileDialog.ShowDialog();
if (fileResult != DialogResult.OK)
return false;
programFileDialog.Dispose();
}
那么为什么 AutoUpgradeEnabled 不起作用?
If I specify OpenFileDialog.AutoUpgradeEnabled = true, my program still shows the old XP-style dialog. Any idea why this would happen? This is after I enable theming in Main()
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Primary());
}
and this is my dialog code:
private void OpenProgramFile()
{
OpenFileDialog programFileDialog = new OpenFileDialog();
programFileDialog.Filter = "Program files (*.exe;*.lnk)|*.exe|All files (*.*)|*.*";
programFileDialog.FilterIndex = 0;
programFileDialog.Title = "Select program file";
programFileDialog.AutoUpgradeEnabled = true;
programFileDialog.ShowHelp = true;
DialogResult fileResult = programFileDialog.ShowDialog();
if (fileResult != DialogResult.OK)
return false;
programFileDialog.Dispose();
}
So why would AutoUpgradeEnabled not work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
避免设置
programFileDialog.ShowHelp=true
。ShowHelp
属性与 Vista/7 文件对话框 UI 不兼容。打开文件对话框仍将显示问号帮助图标。Avoid setting
programFileDialog.ShowHelp=true
. TheShowHelp
property is not compatible with the Vista/7 file dialog UI. The open file dialog will still show a question-mark help icon.如果您想要 Windows Vista 或 Windows 7 风格的对话框,您应该使用 Microsoft Windows API 代码包:http: //code.msdn.microsoft.com/WindowsAPICodePack。这包括所有 Windows 7 样式对话框。
If you want to have Windows Vista or Windows 7 style dialogs you should use the Microsoft Windows API Code Pack: http://code.msdn.microsoft.com/WindowsAPICodePack. This includes all the Windows 7 Style dialogs.