sujith

sujith

  • NA
  • 1
  • 0

accessing controls in container object

Aug 28 2006 3:18 AM
i want to access each and every controls in a form. for this i have written this code below. public void clearText(Form frm){ foreach (Control cnt in frm.Controls){ if (cnt is TextBox) cnt.Text = ""; } } this works if i dont have any container(groupbox,panel) control in the form. for e.g in a form if i have 5 textbox in that 3 are placed directly on the form and 2 are placed inside container control, using the above function i can access only 3 text boxes. how can i access each and every controls in a form.

Answers (2)