I have a form that has a tabcontrol (TabControl1) and within that tab control is another one (TabControl2). I have textboxes on the main form as well as in each of the tabcontrols.
In my savebutton event I have the following code:
If CheckIfDirtyAfterLock = "Just Unlocked" Then
CheckIfDirty(Me.Controls)
Else
'Do Nothing
End If
This calls on the following:
Private Sub CheckIfDirty(ByVal ctrls As Control.ControlCollection)
Try
For Each ctrl As Control In ctrls
If TypeOf ctrl Is TextBox Then
If DirectCast(ctrl, TextBox).Modified Then
Dim strOut As String = ""
strOut = String.Format("{0} was modified on " & Date.Today.ToShortDateString, DirectCast(ctrl, TextBox).Name)
If Addendum.Text = "" Then
Addendum.Text = strOut
Else
Addendum.Text = Addendum.Text & " | " & strOut
Addendum.Text = Addendum.Text.Trim
End If
End If
' check child controls if any
CheckIfDirty(ctrl.Controls)
End If
Next
Catch ex As Exception
End Try
End Sub
What happens is that it records those textboxes that have changed and writes it to addendum.text. The problem is that it is only capturing those textboxes on my main form and none of the textboxes that get changed within TabControl1 or TabControl2. Anyone have any suggestions as to why this is happening?