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.
Protected Overrides Sub oncreatecontrol() MyBase.OnCreateControl() Me.Text = "Exit" End Sub
This is what I used and it seems to work fine. Now the icon?
Wow what a great deal to digest today.
<ToolboxBitmap(GetType(System.Windows.Forms.Button))>
''' <summary>''' My Button class. I will use this class to exit a form.''' </summary>''' <remarks></remarks><ToolboxBitmap(GetType(System.Windows.Forms.button))>Public Class myExitButton Inherits MicroFour.StrataFrame.UI.Windows.Forms.Button Public Sub New() MyBase.New() Me.Width = 23 Me.Height = 32 Me.Text = "Exit" End Sub Protected Overrides Sub OnClick(ByVal e As System.EventArgs) MyBase.OnClick(e) ' Simply Want to Close the Form Like ' Me.close() End Sub
Of course the three things I want to work don't:
The icon of a button does not show up just a cog wheel on the toolbox. Maybe that is the way it should be.Me.Close will not workme.text="Exit' does not show up.
TIA