Click here to Skip to main content
15,894,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to clear the added textboxes to be cleared from a panel
Posted
Updated 3-Nov-10 23:09pm
v2
Comments
AmitChoudhary10 4-Nov-10 3:46am    
not clear!!

1 solution

C#
ControlCollection controls = pnl.Controls;
        foreach (Control ctrl in controls)
        {
            if (ctrl is TextBox)
            {
                ((TextBox)ctrl).Text = "";
            }
        }


Please vote and Accept Answer if it Helped.
 
Share this answer
 
Comments
Dalek Dave 4-Nov-10 4:51am    
Good Answer!
Tarun.K.S 4-Nov-10 5:24am    
he wants to clear the "added" textboxes to be cleared from the panel. maybe he is talking about removing the textboxes that he "added" from the panel.
Tarun.K.S 4-Nov-10 5:41am    
so if he intends to remove the textbox from panel, then replace the code inside the if condition with this :
pnl.controls.remove(cnt);
Be Yourself 5-Nov-10 8:38am    
U can also use ((TextBox)ctrl).Hide instead

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900