Visual Inheritance Sample

To get samples and instructions for installing them, see the following:

  • Click Samples on the Visual Studio Help menu.

    For more information, see Locating Sample Files.

  • The most recent versions and the complete list of samples are available on the Visual Studio 2008 Samples Web site.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied to a folder under \Program Files\Visual Studio 9\Samples\. For Visual Studio Express Editions, all samples are located on the Internet.

To run this sample

  1. Select Build on the Build menu to compile the project. This allows you to view the derived forms in the Windows Forms Designer.

  2. Press F5.

Demonstrates

A form is a class like any other class in the .NET Framework, 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.

Three forms derive from BaseForm: MainForm, ControlSamples, and MySamples. The BaseForm class includes Label and Button controls and other properties that affect the form's appearance. The derived forms fill in the empty middle area of the form either with examples of using the new My feature or examples of new Windows Forms controls. MainForm is the startup object for the sample; it starts ControlSamples and MySamples.