gpt4 book ai didi

c# - VS 2008 C# 将焦点设置为仅一种形式

转载 作者:行者123 更新时间:2023-11-30 15:06:44 24 4
gpt4 key购买 nike

当我的表单 (AboutForm) 显示时,我需要将焦点放在此表单上(用户应该只能单击“确定”按钮)!

VS2008 需要什么设置?

谢谢!

问候 leon22

最佳答案

你想模态显示它,所以使用ShowDialog()而不是 Show()。就是这样。

例如:

using(var frm = new AboutForm()) {
frm.ShowDialog(this);
}

重要:当使用 ShowDialog 时,关闭窗体不会 Dispose() 它,因此 using;参见 MSDN:

Unlike modeless forms, the Close method is not called by the .NET Framework when the user clicks the close form button of a dialog box or sets the value of the DialogResult property. Instead the form is hidden and can be shown again without creating a new instance of the dialog box. Because a form displayed as a dialog box is hidden instead of closed, you must call the Dispose method of the form when the form is no longer needed by your application.

关于c# - VS 2008 C# 将焦点设置为仅一种形式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7345685/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com