Click here to Skip to main content
15,907,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all

I have more then one textboxes,combobox, radio button and checkboxList in a single form..
Please tell me to clear them all at a time on a button click event.

Thank you
Posted
Updated 7-Dec-12 18:44pm
v2

1 solution

C#
private void button1_Click_1(object sender, EventArgs e)
       {
           List<TextBox> t = new List<TextBox>();

           t.Add(textBox1);
           t.Add(textBox2);
           t.Add(textBox3);
           t.Add(textBox4);

           foreach (TextBox txt in t)
           {
               txt.Clear();
           }

           comboBox1.SelectedIndex = 0;
           checkBox1.Checked = false;
           radioButton1.Checked = false;
       }
   }
 
Share this answer
 
v2
Comments
[no name] 8-Dec-12 0:44am    
No..i have more then one text boxes..i improved the question..please see
[no name] 8-Dec-12 0:49am    
Solution has been updated.. Mark answered if it helped.. :)
[no name] 8-Dec-12 1:05am    
Similarly you can check for the combobox, radiobutton etc..
Surendra0x2 8-Dec-12 1:17am    
gr8 Solution Rohit :)
[no name] 8-Dec-12 1:19am    
Thanks mate.. :)

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