Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Clearing a portion of a Form
Message
 
À
10/04/2009 16:08:55
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Application:
Desktop
Divers
Thread ID:
01394032
Message ID:
01394238
Vues:
39
>Thought you might like to see the code I am using
>
>//Clear previously placed controls
> foreach (Control c in this.Controls)
> {
> if ( (string)c.Tag == "removable")
> {
> this.Controls.Remove(c);
> }
> }

You can't use a foreach and remove controls (or anything from a collection, for that matter). It changes the items in the list and you'll have problems like you're seeing. Use a for loop instead and loop from the last element to the first.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform