8.28 Visual Inheritance

 <  Day Day Up  >  

You want to create a base Windows Form that is used as a template for other Windows Forms.


Technique

Create the base Windows Form and its associated controls within the forms designer. If you want to give derived forms the ability to change the properties of a control within the base form, change that control's Modifiers property. The available modifiers are the same as the access control modifiers explained in Chapter 2, "Objects and Components."

To create a new Windows Form using a base form as a template, click on Project, Add Inherited Windows Form from the main menu. When the Inheritance Picker dialog box appears, select the form to use as the base class. If the base Windows Form is contained within a separate assembly, you can click the Browse button to locate it.

Comments

Visual inheritance is a good time-saving method that allows you to define a common set of controls on a form that you can then customize among a set of derived forms. For instance, you might create a base Windows Form that simply contains a private Label control whose Image property is set to your company's logo. With the requirement that any new Windows Forms should derive from this common form, you can enforce that your logo is always displayed throughout the application. Another advantage is that a change to the base form is propagated to every derived form within the hierarchy. If instead you copied the necessary form code for each form, the amount of changes required to do something as simple as changing the location of a control would be daunting.

 <  Day Day Up  >  


Microsoft Visual C# .Net 2003
Microsoft Visual C *. NET 2003 development skills Daquan
ISBN: 7508427505
EAN: 2147483647
Year: 2003
Pages: 440

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net