I am using VB 2010.

I wanted to put the code below into a save custom control. The problem is that how do I get a command button custom control to recognize the form that the save button custom control sits on? Is it possible to have the code below in a button custom class. If so it would be good because the company will have a "universal save checking" as a default behavior. And our checking occurs when the user leaves the control.


Dim ctrl As Control = Me.GetNextControl(Me, True) 'Get the first control in the tab order.

Do Until ctrl Is Nothing 'Use ctrl here.

If (TypeOf ctrl Is clsTextBox) Then
Dim mtb As clsTextBox = CType(ctrl, clsTextBox)


If Not mtb.IsValidated Then
Exit Do
End If

End If

ctrl = Me.GetNextControl(ctrl, True) 'Get the next control in the tab order.