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 .
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 .
Basically every form is inherited. Your form ReBind is inherited from Windows.Form
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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 ;)
I have tested my code, and the name of the class is enough for the GetType function. No need to have an instance ;)
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.
If TypeOf frm is FormReBind Then
'Place some code
End If
Thank for your help again.