Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to close all child forms
Message
De
25/11/2006 16:07:49
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Titre:
How to close all child forms
Divers
Thread ID:
01172429
Message ID:
01172429
Vues:
137
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform