Use Form Inheritance

Problem

You want to create and apply a consistent template to multiple forms.

Solution

Create a base form class, and derive all other forms from this class.

Discussion

Using inheritance with form classes is just as straightforward as using it with any other type of control class. You can use it to standardize visual appearance for multiple similar windows (for example, in a wizard) or in similar windows in multiple applications.

To use form inheritance, follow these three steps:

  1. Create a base form, and configure as you would any other form.

  2. Compile the project.

  3. Create a derived form.

There are two approaches to create your derived form. You can create it automatically with Visual Studio .NET by right-clicking the project item in Solution ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.