Click here to Skip to main content
15,909,039 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
foreach (Control ctrl in cc)
       {
           TextBox tb = ctrl as TextBox;
           if (tb != null)
               tb.Clear();
           else
               RecursiveClearTextBoxes(ctrl.Controls);
       }


above code i've used for resetting textbox, can anybody help me with something similar to this for checkbox
Posted
Comments
dimpledevani 25-Jun-12 5:24am    
Am sorry but i didnt understood your question properly.You can set the checked property to false for checkbox

If you have managed to do this for TextBoxes, then just replace "TextBox" with "CheckBox", and ".Clear()" with ".Checked = false"

I take it this is "homework of the day"? I seem to have seen this a couple of times already...
 
Share this answer
 
C#
foreach (Control ctrl in cc)
       {
           checkbox cb = ctrl as checkbox;
           if (cb  != null)
               cb.Checked = false;
           else
               RecursiveClearTextBoxes(ctrl.Controls);
       }


you can use as like above or you can use is like below

C#
foreach (Control ctrl in cc)
       {
           if (cb  is checkbox)
               cb.Checked = false;
           else
               RecursiveClearTextBoxes(ctrl.Controls);
}
 
Share this answer
 
v2

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