Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Clearing a portion of a Form
Message
 
To
10/04/2009 16:52:48
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Application:
Desktop
Miscellaneous
Thread ID:
01394032
Message ID:
01394533
Views:
35
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform