Windows Forms: Using Forms Inheritance

This sample shows how you can use inheritance with Windows Forms. A Form is really only a class, like any other class in .NET, except that it has the capability to display visual user interface elements. To use this type of inheritance simply create a class that derives from a class that, in turn, derives from System.Windows.Forms.Form.

Featured Highlights:

Requirements:

This application requires the release version of Visual Studio .NET Professional (or greater) and access to the Northwind database residing in SQL Server or the Microsoft Data Engine (MSDE). To install MSDE, do the following:

1. Open the Start menu, click Programs, click Microsoft .NET Framework SDK, and then click Samples and Quickstart Tutorials.

2. Click "Step 1: Install the .NET Framework Samples Database".

3. Open a command window, and CD to \Samples\Setup This is typically : C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Samples\Setup

4. Type: osql -E -S (local)\NetSDK -i InstNwnd.sql

Running the Sample:

To view the Forms that derive from frmBase (i.e., that use inheritance) in the Designer, you will first have to compile the project. If you open a derived Form (frmRichTextBox or frmDataGrid) before compiling, close the Form, compile, and then reopen the Form.

See also

Advanced Basics: Using Inheritance in Windows Forms Applications