18.01.2013 Views

Mastering Visual Basic .NET

Mastering Visual Basic .NET

Mastering Visual Basic .NET

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

186<br />

Chapter 5 WORKING WITH FORMS<br />

VB6 ➠ VB.<strong>NET</strong><br />

The Form Designer is one of the most improved areas of VB.<strong>NET</strong>. For the first time, you can design forms<br />

that can be easily resized—anyone who has programmed in earlier versions of VB knows what a hassle the<br />

resizing of forms could be. The Anchor and Dock properties allow you to anchor controls on the edges of<br />

the form and dock them on the form. When the form is resized, the controls on it can be either resized or<br />

moved to new locations, so that they remain visible.<br />

If the controls can’t fit the form, scroll bars can appear automatically, so that users can scroll the form in<br />

its window and bring another section into view, if the form’s AutoScroll property is True. Scrolling forms<br />

are also new to VB.<strong>NET</strong>.<br />

A new special control was added, whose sole purpose is to act as a pane separator on forms: the Splitter control.<br />

This control is a thin horizontal or vertical stripe that allows you to resize two adjacent controls. If<br />

two TextBox controls on the same form are separated by a Splitter control, users can shrink one TextBox to<br />

make more room for the other. Again, no code required.<br />

Of course, many things have changed too. You can no longer show a form by calling its Show method. You<br />

must first create an instance of the form (a variable of the Form type) that you want to show and then call<br />

the Show method of this variable. You no longer have arrays of controls. This isn’t much of a problem,<br />

though, because with VB.<strong>NET</strong> you can create instances of new controls from within your code and position<br />

them on the form.<br />

The Appearance of Forms<br />

Applications are made up of one or more forms (usually more than one), and the forms are what<br />

users see. You should craft your forms carefully, make them functional, and keep them simple and<br />

intuitive. You already know how to place controls on the form, but there’s more to designing forms<br />

than populating them with controls. The main characteristic of a form is the title bar on which the<br />

form’s caption is displayed (see Figure 5.1).<br />

Figure 5.1<br />

The elements of<br />

the form<br />

Control<br />

menu<br />

Title bar<br />

Minimize<br />

button<br />

Maximize<br />

button<br />

Close<br />

button

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!