
Creating and Displaying
New Forms
Most of this book so far has dealt with building forms. Previous lessons explained how to add,
arrange, and handle the events of controls on a form. They’ve explained how to work with
specific kinds of controls such as
MenuStrips, ContextMenuStrips, and ToolStrips. Using
these techniques, you can build some pretty nice forms that use simple code to manipulate
properties. So far, however, you’ve only learned how a program can use a single form.
In this lesson you learn how to display multiple forms in a single program. You see how to
add new forms to the project and how to display one or more instances of those forms. Once
you’ve mastered these techniques, you can make programs that display any number of forms
for all kinds of different purposes.
ADDING NEW FORMS
To add a new form to a project, open the IDE’s Project menu and select Add Windows Form to
see the dialog shown in Figure 9-1.
Leave the Windows Form template selected, enter a good name for the new type of form,
and click Add. After you click Add, Visual Studio adds the new form type to the project.
Figure 9-2 shows the new form in Solution Explorer.
Now you can add
Labels, TextBoxes, Buttons, MenuStrips, and any other controls you like
to the new form.
Remember, to open a form in the Form Designer, double-click it in Solution
Explorer.
9
596906c09.indd 103 4/7/10 12:32:17 PM