'clear' function won't work
ok, I have several functions of which each clear (initialize) each individual control encountered on a form (textbox, combobox, etc)
They work like a charm UNLESS those controls are on a tab that is on a tab. ex. I have a main tab control and the controls (tabs and its controls) get cleared fine. I have other tab controls sitting on that main one. THOSE tabs and the controls sitting on those aren't getting touched. following are the basic fuctions:
VB Code:
'***************************************************************************************************
'Initialize the tab pages
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is TabControl Then
ClearTabControl(ctrl)
End If
Next
VB Code:
Public Sub ClearListBox(ByVal box As ListBox)
'Purpose : Clear a list box of all items
'Accepts : listbox control
'Notes :
box.Items.Clear()
End Sub
Public Sub ClearTabControl(ByVal tc As TabControl)
'Purpose : clears all tabpages on a tabpage control
'Accepts : control as tabcontrol
'Returns :
'Notes :
For Each ctrl As Control In tc.Controls
Try
If TypeOf ctrl Is TabPage Then
ClearTab(ctrl)
End If
Catch ex As Exception
End Try
Next
End Sub
Public Sub ClearTab(ByVal tab As TabPage)
'Purpose : Clears an entire tab control of data
'Accepts : tabpage control
'Notes : this sub calls on other subs to do the work
For Each ctrl As Control In tab.Controls
Try
'Clear all textboxes
If TypeOf ctrl Is TextBox Then
TextBoxClear(ctrl)
End If
'Next, ComboBoxes
If TypeOf ctrl Is ComboBox Then
ComboBoxClear(ctrl)
End If
'Next, Groupboxes
If TypeOf ctrl Is GroupBox Then
GroupBoxClear(ctrl)
End If
'Next, other Tabs
If TypeOf ctrl Is TabPage Then
ClearTab(ctrl)
End If
'Next, Listboxes
If TypeOf ctrl Is ListBox Then
ClearListBox(ctrl)
End If
Catch
End Try
Next
End Sub
Public Sub ComboBoxClear(ByVal Box As ComboBox)
'Purpose : Resets a combobox to the first item in the collection list
'Accepts : combox as argument
'Notes : This doesn't delete any info, it just resets the box
Try
Box.Text = Box.Items.Item(0)
Catch
End Try
End Sub
Public Sub GroupBoxClear(ByVal groupbox As GroupBox)
'Purpose : Clear all textboxes within a groupbox control
'Accepts : groupbox as argument
'Notes :
For Each ctrl As Control In groupbox.Controls
Try
If TypeOf ctrl Is TextBox Then
TextBoxClear(ctrl)
End If
If TypeOf ctrl Is ComboBox Then
ComboBoxClear(ctrl)
End If
Catch
End Try
Next
End Sub
Public Sub TextBoxClear(ByVal box As TextBox)
box.Text = String.Empty
End Sub
apparantly, i'm missing something when program control goes to TAB CONTROL .:confused: