Changes

Jump to: navigation, search

Designing Forms in Visual Studio

4 bytes added, 19:19, 13 August 2007
no edit summary
The primary purpose of Visual Basic is the development of graphical Windows applications. Given this fact, it is not surprising that an important part of developing with Visual Basic involves the design of Windows Forms. In this chapter of Visual Basic Essentials , we will cover in great detail the design of Forms using Visual Studio.
== Visual Basic Forms and Controls ==
* '''LayoutMode''' - Controls whether controls are laid out by snapping to a grid location, or are aligned with other controls in the form. Aligning with other controls is achieved using "Snap Lines" which are covered in detail in the next section of this chapter.
Spend some time changing the settings and adding new controls or move existing form controls. In particualr particular, try different ''GridSize'' and ''SnapToGrid'' settings.
== Positioning Controls Using Snap Lines ==
It is often useful to be able to select multiple controls in a form. Normally when you click on one control in a form, the currently selected control is deselected. There are two ways to select multiple controls. One method is to hold down the ''Shift'' key while selecting controls. With the ''Shift'' key pressed any currently selected controls will remain selected while other controls are clicked.
Another method is to ''rubber band'' the controls. To do this click on any empty area fo teh of the form to the top left of the group of controls you wish to select. With the mouse button depressed drag to draw a box around the controls. When you release the mouse button all the controls within the box area will be selected.
To deselect de-select individual controls from a group of selected controls, simply hold down the ''Shift'' key and click with the left hand mouse button on the control to deselectde-select.
Once a group of controls are selected you can move all the controls at once, maintaining their positions relative to each other, simply by clicking and dragging the entire group.
== Setting Tab Order in a Form ==
Despite the advent of the graphical user interface and the mouse, it is still common for users to navigate forms using the keyboard. The standard keyboard navigation technique involves the use of the ''Tab'' key to move from one control to the next in form. For this reason it is vital that the ''Tab Order'' be configured to implenent implement a sensible sequence of moves between controls.
To view and change the current tab order for a form, display the ''Layout'' toolbar (if this is not already visible, right click on the standard Visual Studio toolbar and select ''Layout''). On the Layout toolbar click the ''Tab order'' button (usually the last button on the right). The form will be displayed with a number next to each control:

Navigation menu