[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-11-17
5
Medium Priority
?
256 Views
Last Modified: 2010-04-24
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 .
0
Comment
Question by:quangnv2005
5 Comments
 
LVL 28

Expert Comment

by:iboutchkine
ID: 12603512
Basically every form is inherited. Your form ReBind is inherited from Windows.Form
0
 
LVL 4

Accepted Solution

by:
Glom earned 750 total points
ID: 12604100
Hi,

I think what you need could be written like this :

If frm.GetType.IsSubclassOf(GetType(FormReBind)) Then

0
 
LVL 4

Expert Comment

by:Jigit
ID: 12605047
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
0
 
LVL 4

Expert Comment

by:Glom
ID: 12605088
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 ;)
0
 

Author Comment

by:quangnv2005
ID: 12610414
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.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month19 days, 7 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question