Designing Effective Forms

function OpenWin(url, w, h) { if(!w) w = 400; if(!h) h = 300; window.open(url, "_new", "width=" + w + ",height=" + h + ",menubar=no,toobar=no,scrollbars=yes", true); } function Print() { window.focus(); if(window.print) { window.print(); window.setTimeout('window.close();',5000); } }
Team-Fly    

Special Edition Using Microsoft® Visual Basic® .NET
By Brian Siler, Jeff Spotts
Table of Contents
Chapter 14.  Designing an Effective User Interface


Forms are the building blocks of your user interface. Although the process of designing a form in Visual Basic is simple, doing it well is not very easy. Good form design involves more than just adding controls and writing code. To make a well-designed form, you should understand the form's purpose, how it is going to be used, when it is going to be used, and its relationship with the rest of the program. In addition, within your application, you may have several forms, each of which must be displayed when appropriate. Some users take advantage of the multitasking freedom offered by Windows, whereas others tend to use only one application at a time. Keep this point in mind when you're designing a user interface (UI): You must manage the flexibility that Windows and the .NET framework offer to the programmer so that users with any skill level can effectively use your applications.

Keep Forms Neat and Uncluttered

The more controls you have on a form, the more important it is to keep them organized. Consider the form shown in Figure 14.1. It looks as though the controls have been placed on the form haphazardly. They are not labeled, lined up, or sized consistently. A better approach is shown in Figure 14.2. Notice that frames, lines, and labels have been added to group related controls. Both illustrations show "working" applications, but the second form has a more visually pleasing appearance, which makes it easier to use.

Figure 14.1. A messy form can prevent users from finding the information they need.

graphics/14fig01.gif

Figure 14.2. In a much better design than the form shown in Figure 14.1, frames and labels are used to organize the form.

graphics/14fig02.gif

Visual Basic provides several excellent controls to help you organize a form. One of these controls is the TabControl control, shown in Figure 14.3, which can be used to segregate controls so that only a few of them are displayed at any given time. This way, you can hide infrequently used options from the average users while still making them available if necessary.

Figure 14.3. Use the TabControl control to keep your form a reasonable size.

graphics/14fig03.gif

To keep from going overboard with too many controls on a form, you should always keep the form's purpose in mind. Consider the form in Figure 14.3. Everything on the form could fall under the general realm of "Program Options," but each separate category of options is in a different section of the TabControl control. If you do find that you need a separate form, make sure logic dictates which controls you put on it.

In addition, make sure to set the appropriate form properties so that the form acts according to its intended purpose. For example, a form that acts as a dialog box should not have a sizeable border or show up in the Windows taskbar. Dialog boxes are discussed in Chapter 13, "Using Dialog Boxes."

For more information on the standard customizable features of dialogs, p. 335

Pay Special Attention to Data Entry Forms

Data entry forms are a special breed. They should allow users to work at their own pace, not the programmer's. Common sense is the main rule here: If users have to enter thousands of records into your database, they don't want to answer a yes/no confirmation dialog box for each record.

The preceding section emphasized separating and hiding certain controls. However, a data entry form should maximize the use of form space because showing and hiding forms slows down the process. Speed and ease of use should definitely be among your main goals when designing a data entry form. To make the data entry process faster, follow these guidelines:

  • Always provide keyboard shortcuts; never require the use of a mouse. (This is good advice for all forms in your program, not just data entry forms.)

  • Keep the layout consistent with the order of the users' tasks. In other words, don't make them jump from one section to another unnecessarily to enter information. If the users are entering information from a paper-based form, the flow of information on your program's interface should match the flow of the paper form as closely as possible.

  • Do not require the users to perform unnecessary work. In other words, if fields 2 through 10 require a value only if field 1 has a value, you don't need to make the users always tab through every field. On the other hand, don't make the behavior of your forms too field-dependent; if a form works differently for every possible combination of required fields, you may actually slow down the user.

  • Use noticeable but unobtrusive visual and/or audio cues to provide feedback to the users. The way the Visual Basic .NET code editor capitalizes correctly spelled variables and constants is a good example of a visual cue.

  • If possible, perform adds and edits on the same form so that the users do not have to learn multiple methods of accessing the same data.

An example of a well-designed data entry form is shown in Figure 14.4. Notice that the form's status bar shows an explanation of each field as it is entered.

Figure 14.4. In a data entry form, ease of use is of prime importance.

graphics/14fig04.gif

Use the Right Control for the Job

Visual Basic provides a number of controls that can be placed on a form. However, keep in mind that some controls work better in certain situations than others. The purpose of the form should help guide you in choosing the appropriate controls. For example, both the ListBox and ComboBox controls can be used to select from a list of choices. However, the combo box allows you to save form real estate by hiding the list of choices, as illustrated in Figure 14.5.

Figure 14.5. The amount of space available on a form may influence your choice of custom controls.

graphics/14fig05.gif

In Figure 14.5, list boxes could have just as easily been used for the selection criteria. However, using a combo box is more appropriate because it saves space while still accomplishing the intended task.

To learn more details for creating a combo box, p. 305

Third-Party Controls

Third-party controls are useful; however, you should not use them unless doing so is really necessary. Picking a control included with Visual Studio .NET over a third-party control offers several advantages:

  • The chances are better that the control will be supported in future versions of Visual Studio.

  • Distributing the control to users is easier.

  • Many "native" Visual Studio controls provide the users an interface with which they are already familiar.

Multiple Forms

If your user interface will contain multiple forms, a major decision you have to make is whether to use a single-document interface (SDI) or a multiple-document interface (MDI). Multiple-form programs, discussed in Chapter 15, "Multiple Document Interface (MDI) Applications," handle multiple forms by enclosing them visually within a "parent" window.

To create an app that lets users manage multiple windows, p. 384

Forms in an SDI application appear as totally independent windows. Whether you use SDI or MDI, user interaction with forms initiates many program actions through form and control events. If you have multiple forms, you need to code the program so that the users are not allowed to disrupt the intended program flow for example, show a data form that has not been populated yet.

Figure 14.6 shows an example of what can happen if you do not sufficiently control your user's ability to open windows at will.

Figure 14.6. It is important to control how and when your users may open multiple windows.

graphics/14fig06.gif


    Team-Fly    
    Top
     



    Special Edition Using Visual Basic. NET
    Special Edition Using Visual Basic.NET
    ISBN: 078972572X
    EAN: 2147483647
    Year: 2001
    Pages: 198

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