C# this.Controls.Remove problem
        Posted  
        
            by arnoldino
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by arnoldino
        
        
        
        Published on 2010-05-14T15:35:13Z
        Indexed on 
            2010/05/14
            15:44 UTC
        
        
        Read the original article
        Hit count: 447
        
What is the problem with this code?
for (int w = 0; w < this.Controls.Count; w++)
{
    if (this.Controls[w] is TransparentLabel)
    {
        la = (TransparentLabel)this.Controls[w];
        if (la.Name != "label1")
        {
            la.Visible = false;
            la.Click -= new System.EventHandler(Clicked);
            this.Controls.Remove(this.Controls[w]);
            la.Dispose();
         }
     }
}
I want to clear the screen from the labels, but it doesn't work.
© Stack Overflow or respective owner