views:

222

answers:

3

Like Master pages in ASP.NET, do we have any similar concept for Windows Form application. So that I dont have to repeat the same portion of form (Header and footer) many times through out the application.

+2  A: 

Create a form class that defines the components you want, and make all your other forms a subclass of this form class.

Here is a good example in VB.NET.

crb
A: 

You can create a base form class with the controls that will be on every form of that type, and then derive all of your actual forms from that base class. This is called "Visual Inheritance", and the Windows Forms designer has some nice design-time support for this.

Alternatively, you might also look into the notion of having one actual form with your header and footer fields and a big blank panel where your individual "pages" will go. Make each page a user control and swap them in and out as needed at run-time. This is a standard way of making "wizard" dialogs, for example.

Jesse Smith
+2  A: 

That is what UserControls are for in Windows Forms.

Basically, you would create the "master" form and then the master form would be initialized with the types of the user controls that would go in the "placeholders". The form would just then create the controls given the Type instance(s) and add the instances to the Controls collection.

casperOne