Re: Closing MDI Parent form
An MDI child form cannot be a modal dialogue. To prevent the parent form closing you can handle the FormClosing event:
Code:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
// Cancel the closing action if and only if there are child forms.
e.Cancel = (this.MdiChildren > 0);
}
Note that this assumes that you're using VB2005. In previous versions you'd handle the Closing event instead. Please make sure you specify your version in future.
Also, this will prevent Windows shutting down if your app has child forms open. You'd have to make a special case for if the system was shutting down. I don't know exactly how to do that because I've never had to myself but I know that the appropriate code has been posted before.
Re: Closing MDI Parent form
Thats a great reply. Thank u so much
Just one more doubt added to it.
i am having parent form(mainfrm)
i am having 2 child forms(frm1,frm2)
i will go to frm1 and frm2 through mainfrm
if frm1 or frm2 is open, i should not able to select mainfrm
like frm1.ShowDialog();
but if i am using this in MDI i am getting error
Can i get answer for this one too.
Thank u so much in Advance
Regards
Vinay Kumar