Reputation:
I want code for hiding multiple child forms in MDI. whenever i click child form it must be in front.other forms will automatically hide. How can i do this? pls any one reply me.
Thanks in advance
Upvotes: 0
Views: 5004
Reputation: 28699
If you watch the MdiChildActivate event, you hide all MDI children that are not active like this:
private void MDIMain_MdiChildActivate(Object sender, EventArgs e) {
foreach(From f in this.MdiChildren)
{
if(this.ActiveMdiChild != f)
f.Hide();
}
}
Upvotes: 2
Reputation: 6192
In Windows, there can be only form that is active at any point of time. So when user clicks on one form, if you set it to active, that should automatically accomplish what you are asking.
if 'frmObj' is your child form, just call frmObj.Activate() method on it.
You may also try to set the WindowState property (frmObj.WindowState) to maximized or whatever you like.
Upvotes: 0