The ACME Company

Figure 9.20: A form that is used to demonstrate visual inheritance.

You need to build the project before visual inheritance can be demonstrated, so press Ctrl+Shift+B or choose the Build | Build menu item.

Next, choose Add Inherited Form from the Project menu. The Add New Item dialog appears, as shown in Figure 9.21.

+ _| Local ptcíbcí Lt«re.

■— 3 J!

■'in

-«Off

it

&

ÍHft

i

ti

r?i

—J

fliflrFi;

Í1KÍWH

MfUPiJf

3

i

i|iiw(rdfi>m Wtbiurtim

J

a n«M farm bs»doi»-an exSbraQ Wndw* flirm

CfMn

Figure 9.21: The Add New Item dialog.

Make sure that Inherited Form is selected in the Templates pane, choose a name for your new form, and click Open. The Inheritance Picker dialog opens, as shown in Figure 9.22, and displays a list of all the forms in your dialog from which you can derive your new form.

liulirril .nV d Pteket

Cmoffiflri Hino [ heni Mar* [ Lacflfaifl '

Fiftl Vgtfm#riw,t C^tvWi Cmi" I

Nw cwipmwl rap* Fhf^

Figure 9.22: Choosing a form to inherit using the Inheritance Picker dialog.

Choose the form, click OK, and a new form class is added to your project. When you look at the design view, you'll see that the new form has inherited all the controls from its parent, and that the controls are marked with a small arrow, very much like the one used to mark a file shortcut, to give you a clue that they are inherited.

And of course, you can have as many levels of inheritance as you like—deriving Form3 from Form2, which in turn is derived from Form1—adding new controls and functionality at each level.

0 0

Post a comment