I have a winform with a number of user controls. On of the control is a
tab control which contains a number of pages where each page has
textboxes and other controls on it. I would like to loop through all
the texboxes on one of the tab pages and empty each and every one of
them. However, I only manage to loop through the separate tab pages and
not their content. Any ideas?
/erik
JezB - 18 Jul 2006 12:48 GMT
You need a recursive iteration. The form has a Controls collection, but
certain controls may also have their own Controls collection.
>I have a winform with a number of user controls. On of the control is a
> tab control which contains a number of pages where each page has
[quoted text clipped - 3 lines]
> not their content. Any ideas?
> /erik
Pritcham - 18 Jul 2006 12:56 GMT
Hi
Something like the following should do:
Private Sub ClearControls(ByVal caller As Object, ByVal lock As
Boolean)
Dim ctl As Control
For Each ctl In caller.Controls
If ctl.HasChildren Then
ClearControls(ctl, lock)
End If
If TypeOf ctl Is Windows.Forms.TextBox Then
ctl.Text = String.Empty
End If
Next
End Sub
Hope that helps
Martin
> I have a winform with a number of user controls. On of the control is a
> tab control which contains a number of pages where each page has
[quoted text clipped - 3 lines]
> not their content. Any ideas?
> /erik