Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
MyBase.OnClick(e)
Dim parentform As Form = Me.GetParentForm()
If parentform IsNot Nothing Then
parentform.Close()
End If
End Sub
Protected Overrides Sub oncreatecontrol()
MyBase.OnCreateControl()
Me.Width = 75
Me.Height = 23
Me.Text = "Exit"
End Sub
Private Function GetParentForm() As Object
' return var
Dim parentform As Form = Nothing
Dim ctl1 As Control = Me.Parent
If TypeOf ctl1 Is Form Then
parentform = DirectCast(ctl1, Form)
Return parentform
End If
Do
ctl1 = Me.GetNextControl(ctl1, True)
If ctl1 IsNot Nothing Then
' Search for Form
If TypeOf ctl1 Is Form Then
parentform = DirectCast(ctl1, Form)
End If
End If
Loop Until ctl1 Is Nothing
Return parentform
End Function
The above works but of course I am sure I did not do it the best way. Any suggestions would be appreciated.
Thank you again.