Creating the Inherited Form

Topic Objective

To explain how to create an inherited form.

Lead-in

Creating an inherited form is simple.

After you have designed your base form and built the solution, you are ready to begin deriving forms. To do this, you simply add a new item to the project by clicking Inherited Form in the Add New Item window. This will run the Inheritance Picker for you.

When inheriting from a base Windows Form, consider the following guidelines carefully:

■ Ensure that the base form is as complete as possible.

Make any last minute changes to the base form before inheriting from it.

■ Reference the assembly.

If the base form is not in the same project, you must make a reference to the appropriate assembly.

■ Create a new Inherited Form item.

Add a new Inherited Form item to your project, selecting the base form in the Inheritance Picker dialog box. A list of available base forms is shown, and you can browse for other assemblies.

■ Change control properties where necessary.

You can programmatically change public and protected controls, and you can use the Properties window of the Windows Forms Designer for a derived form. Private controls cannot be altered outside of the base form.

■ Override methods or events as required.

If methods or event handlers have been marked as overridable, you can implement your own code in the derived form.

0 0

Post a comment

  • Receive news updates via email from this site