empty textBoxes
-
lets say i have tabpages with lots of textboxes on each page. (winform) is there a shoort way to empty all textboxes on each page?
I use code like the following to set control's to their default values. You can either pass in the tab page to the function or modify it slightly and pass in the tab control and step through the control's pages. private void ClearTextBoxes (Control parentControl) { // Step through each control in the parent control and clear it's text if a textbox foreach (Control control in parentControl.Controls) { if (control is System.Windows.Forms.TextBox) control.Text = string.Empty; } } This method has the added advantage that you can also default check boxes' and other controls' properties by adding an additional if (control is [control type]) statement in the for loop. Hope this helps Aaron
-
I use code like the following to set control's to their default values. You can either pass in the tab page to the function or modify it slightly and pass in the tab control and step through the control's pages. private void ClearTextBoxes (Control parentControl) { // Step through each control in the parent control and clear it's text if a textbox foreach (Control control in parentControl.Controls) { if (control is System.Windows.Forms.TextBox) control.Text = string.Empty; } } This method has the added advantage that you can also default check boxes' and other controls' properties by adding an additional if (control is [control type]) statement in the for loop. Hope this helps Aaron