我在我的软件菜单条中,当用户点击时,我想打开另一个子窗口,但我想禁用父窗口,这意味着只需关闭或点击kk使其再次可用。
我当前的代码会打开表单但不会使父禁用
if (about == null)
{
about = new aboutForm();
about.ShowDialog(this);
}
我试过about.ShowDialog();它会抛出错误
我感谢任何答案可能的代码解决方案
答案 0 :(得分:0)
不需要条件,因为ShowDialog(this)
会显示模态对话框。
aboutForm about = new aboutForm();
about.ShowDialog(this);
在aboutForm :
public partial class aboutForm: Form
{
public aboutForm()
{
InitializeComponent();
}
private void aboutForm_Load(object sender, EventArgs e)
{
this.FormClosing +=new FormClosingEventHandler(aboutForm_FormClosing);
}
private void aboutForm_FormClosing(object sender, FormClosingEventArgs e)
{
this.DialogResult = DialogResult.OK;
}
}