【发布时间】:2017-06-20 03:56:28
【问题描述】:
我想禁用我的应用程序的背景窗口,直到顶部窗口关闭。就像错误消息窗口一样。
【问题讨论】:
我想禁用我的应用程序的背景窗口,直到顶部窗口关闭。就像错误消息窗口一样。
【问题讨论】:
您可以通过 ShowDialog 做到这一点:
public void ShowMyDialogBox()
{
using(var testDialog = new Form2())
{
// Show testDialog as a modal dialog and determine if DialogResult = OK.
if (testDialog.ShowDialog(this) == DialogResult.OK)
{
// Read the contents of testDialog's TextBox.
this.txtResult.Text = testDialog.TextBox1.Text;
}
else
{
this.txtResult.Text = "Cancelled";
}
}
}
【讨论】:
当您显示新窗口时,您需要使用 ShowDialog 函数 - 而不仅仅是 Show 函数:
Window dialogWindow = new Window()
dialogWindow.ShowDialog()
【讨论】: