The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Visual Inheritance Sample

This sample shows how you can use inheritance with Windows Forms.

To get samples and instructions for installing them

  • Do one or more of the following:

    • On the Help menu, click Samples.

      The Readme displays information about samples.

    • Visit the Visual Studio 2008 Samples Web site. The most recent versions of samples are available there.

    • Locate samples on the computer on which Visual Studio is installed. By default, samples and a Readme file are installed in drive:\Program Files\Microsoft Visual Studio 9.0\Samples\lcid. For Express editions of Visual Studio, all samples are located online.

For more information, see Visual Studio Samples.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

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.

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.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft