Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Clearing a portion of a Form
Message
 
À
10/04/2009 16:52:48
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:
01394533
Vues:
36
>Well I tried this
>
>for (int i = this.Controls.Count; i >= 0; i--)
> {
> if ((string)this.Controls[i].Tag == "removable")
> {
> this.Controls.RemoveAt(i);
> }
> }
>
>and still no luck. The count is always equal to 1.

That should fail at runtime because Controls.Count is off by one. This code works (at least in my simple test code):
int controlsCount = this.Controls.Count - 1;
for (int i = controlsCount; i >= 0; i--)
{
    if ((string)this.Controls[i].Tag == "removable")
    {
        this.Controls.RemoveAt(i);
    }
}
-Paul

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

Click here to load this message in the networking platform