Link to home
Start Free TrialLog in
Avatar of quangnv2005
quangnv2005

asked on

Howto: Determine the Form that is inherited from another form.

I have this base Form:
Public Class FormReBind
    Inherits System.Windows.Forms.Form

    Event ReBinding()
#Region " Windows Form Designer generated code "
    Public Sub ReBind()
        RaiseEvent ReBinding()
    End Sub
End Class

and inherited Form is:
Public Class Form1
    Inherits FormReBind
....
In Form Main:
   Dim frm as Form
   If frm is FormReBind then <== Howto?
      'Place some code
   End if

Thanks for helping .
Avatar of iboutchkine
iboutchkine

Basically every form is inherited. Your form ReBind is inherited from Windows.Form
ASKER CERTIFIED SOLUTION
Avatar of Glom
Glom
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Glom is right, but you have to put an instance of base class to get its type:

Dim frm as New Form()
Dim frmReBind as New FormReBind()

If frm.GetType.IsSubclassOf( frmReBind.GetType() ) Then
      'Place some code
End if

HTH,
Jigit
Hi Jigit,
I have tested my code, and the name of the class is enough for the GetType function. No need to have an instance ;)
Avatar of quangnv2005

ASKER

Thanks Glom, it's work. And with your approach I found another way, like:

If TypeOf frm is FormReBind Then
    'Place some code
End If

Thank for your help again.