Hi All,
Could someone please help me, i want to clear all the controls on my for before realoading the next set of information. I have worked out how to do it with this code. The problem is the tabs I am using are ultratabs and I can't work out how to modify the code to work for them:
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is TextBox Then
DirectCast(ctrl, TextBox).Text = ""
End If
If TypeOf ctrl Is TabControl Then
For Each cc As Control In aTabPage.Controls
If TypeOf cc Is TextBox Then
DirectCast(cc, TextBox).Text = ""
Next
The following recursive method should clear the text of all text boxes on the form:
Private Sub btClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btClear.Click Me.ClearText(Me)End Sub
Private Sub ClearText(ByRef ctrl As Control) For Each subCtrl As Control In ctrl.Controls If TypeOf subCtrl Is TextBox Then DirectCast(subCtrl, TextBox).Text = "" Else Me.ClearText(subCtrl) End If NextEnd Sub