Form inheritance.

C

CypherDrive

Dear All,

We developed a Form (Entry Form) and set it's properties using the IDE of
VB.NEt

Then we created another form and decided to inherit the form and the tools
on the form.

How do I inherit the Entry Form Programmatically?

Thanks,
CypDr
 
M

Morten Wennevik [C# MVP]

CypherDrive said:
Dear All,

We developed a Form (Entry Form) and set it's properties using the IDE of
VB.NEt

Then we created another form and decided to inherit the form and the tools
on the form.

How do I inherit the Entry Form Programmatically?

Thanks,
CypDr

Hi CypDr,

Use the Inherits keyword to make one class inherit another.

Public Class MyForm
Inherits SomeOtherForm

End Class

If you want to implement interfaces as well, use the Implements keyword on
the line below Inherits.
 
Z

Zhi-Xin Ye [MSFT]

Dear CyhperDrive,

You can take the following steps to inherit a form programmatically.

1. If the form you wish to inherit from is not in the same namespace as
your class, then in your class, add a reference to the namespace containing
the form you wish to inherit from. e.g.

Imports Namespace1

2. In the class definition, add a reference to the form to inherit from.
The reference should include the namespace that contains the form, followed
by a period, then the name of the base form itself. e.g.

Public Class Form2
Inherits Namespace1.Form1
....
End Class

However, if the form you wish to inherit from is in the same namespace as
your class, then you can omit the namespace, i.e. just put the name of the
base form after the Inherits keyword.

When inheriting forms, there's one important thing we should put attention
to: because each event can be handled by both the base form and the
inherited form, means each event handlers may be called twice.
To avoid this, you can refer to this document:

[ Troubleshooting Inherited Event Handlers in Visual Basic .NET ]
http://msdn.microsoft.com/en-us/library/e33683a5(VS.71).aspx

To learn more about the form inheritance, you can refer to these articles:

[ Everything you wanted to know about Forms Inheritance in VB.NET ]
http://www.codeproject.com/KB/dotnet/BestFormInheritance.aspx

[ Windows Forms Inheritance ]
http://msdn.microsoft.com/en-us/library/aa983613(VS.71).aspx

If you need more information about this, please don't hesitate to let me
know.

Sincerely,
Zhi-Xin Ye
Microsoft Managed Newsgroup Support Team

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top