问题
I menu strip in my software and when users click on about I want to open the another child window but I want to make the the parent window disabled which means only by closing or clicking kk make it available again.
My current code opens the form but does not make the parent disable
if (about == null)
{
about = new aboutForm();
about.ShowDialog(this);
}
I tried about.ShowDialog(); it's throws a error
I appreciate any answers possible code solutions
回答1:
Condition is not required because ShowDialog(this)
would show modal dialog.
aboutForm about = new aboutForm();
about.ShowDialog(this);
In 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;
}
}
来源:https://stackoverflow.com/questions/24053309/disable-mdi-parent-when-child-is-active