Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to close all child forms
Message
From
25/11/2006 16:07:49
 
 
To
All
General information
Forum:
ASP.NET
Category:
Forms
Title:
How to close all child forms
Miscellaneous
Thread ID:
01172429
Message ID:
01172429
Views:
136
I have .net 1.1 WinForms MDI application.

I need to close all MDI child forms.
I tried
private void CloseAllForms_Click(object sender, System.EventArgs e){

foreach (Control c in this.Controls) {
  if (c is MdiClient)
    ((Form)c).Close();
  }
}
but got error

"Unable to cast object of type 'System.Windows.Forms.MdiClient' to type 'System.Windows.Forms.Form'."

Why ?

I also tried c.FindForm().Close();
but this closes whole application.
Andrus
Next
Reply
Map
View

Click here to load this message in the networking platform