... Public Class cmdbase Inherits System.Windows.Forms.Button ...This class sets just some properties which all buttons have in common like size, color etc.
Public Class cmdexit Inherits cmdbaseThis button gets a special text, an image and some special behaviour:
Public Sub New() MyBase.New() InitializeComponent() 'Me.Text = "&Ende" Me.ImageAlign = System.Drawing.ContentAlignment.TopCenter End Sub Protected Overrides Sub OnPaint(ByVal pevent As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(pevent) Me.Text = "&Ende" End Sub Protected Overrides Sub OnClick(ByVal e As System.EventArgs) Dim meth As MethodInfo = Me.Parent.GetType().GetMethod("DoExit") If meth = Nothing Then 'MsgBox("Methode fehlt") Else 'MsgBox("Methode da") meth.Invoke(Me.Parent, Nothing) End If MyBase.OnClick(e) End SubThere is a baseform which has a DoExit-Method which just executes the me.close() command.
Public Overridable Sub DoExit() If Not Me.lIsRunning Then ' A property to check if the form is busy MsgBox("Base doexit") Me.Close() Else MsgBox("Isrunning") End If End SubThis button shall look if his parent (a Form) has a Method doexit and if, shall execute it.
dim frm as new form2 frm.showdialog()the method in the baseform is executed (I have same messageboxes implemented for testing reasons) but the