Base Windows Form Class (newby)

F

Fred Nelson

I'm working on a VB.NET application and I have heard that there are many
benefits to creating a base form class and using it. In my case I have
several user controls that I routinely put on each page and it would be
great to make changes to only one form and have them change all forms.

The problem is - I can't figure out how to create one and MSDN assumes that
you already know how!

Does anyone know where there is a tutorial on how to do this?

I would greatly appreciate it!

Thanks,

Fred
 
G

Gary Vidal

Home
You can only use single line of Inheritance although each class can
implement multiple interfaces
(Contract no implementation)
Public Class BaseForm : Inherits System.Windows.Forms.Form

'Your form base code in here

End Class

Public Class InheritedForm : Inherits MyNamespace.BaseForm

End Class
 
F

Fred Nelson

David:

I'm confused!?

I have several user controls that I put on my forms already.

A book that I'm reading says that you can create your own base form so that
you can inherit from it rather than placing the controls on each new form.
If you do this then you don't need to put your user controls on each form as
they are already there. Also I have some security code that I would like to
put in the base form so I don't run the chance of not including it on each
page.

Is there an alternative to putting all the user controls on each form?

Thanks again,

Fred




David Coe said:
Fred -

What you are looking to do is make a UserControl (.ascx) file that you can
drop on each page. This control acts like a traditional include file in
ASP, with full code behind support. When you make a change to the control
file, the changes will be displayed everywhere the control is placed.
 

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

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top