Chapter 14 Managing Windows Forms and Controls at Run Time 371
the button object and the top and left edges of the form changes, the distance to
the bottom and right edges remains constant, as shown here:
- Experiment with the Anchor and Dock properties for a while, and try a different
bitmap image if you like. When you’re finished, click the Close button on the form to
end the program.
You now have the skills necessary to add new forms to a project, position them on the
Windows desktop, populate them with new controls, and align the controls by using program
code. You’ve gained a number of useful skills for working with Windows forms in a program.
One Step Further: Specifying the Startup Object
If your project contains more than one form, which form is loaded and displayed first when
you run the application? Although Visual Basic normally loads the first form that you created
in a project (Form1 .vb), you can change the form that Visual Basic loads first by adjusting
a setting in the Visual Studio Project Designer, a handy tool that I’ll introduce here.
The following exercise shows you how to change the first form, or startup form, by using the
Project Designer.
Switch the startup form from Form1 to Form2
- Click the Close Project command on the File menu, and then create a new Windows
Forms Application project named My Startup Form. - Display Form1 .vb, if it isn’t already visible.
- Click the Add Windows Form command on the Project menu.
You’ll add a new form to the project to demonstrate how switching the startup form
works.