Controls Design

 

Introduction 

When creating an application, your primary job will consist of adding objects called Windows controls, or simply controls, to the application. These controls are what the users of your application use to interact with the computer. Therefore, you will select the necessary controls and add them to your application before configuring their behavior.

To support the idea of rapid application development (RAD), the Visual Studio .Net IDE provides the necessary objects on the Toolbox located on the left side of the screen. To select an object to add to your application, you can first display or expand the Toolbox. To do this, you can position the mouse on the Toolbox bar. This expands the Toolbox and displays its list of Windows controls.

As long as the mouse is positioned on it, the controls would be available. If you move the mouse away, the Toolbox would go back. This is convenient if you want to select one or only a few objects. If you are designing a controls-intensive application, you may want the Toolbox to stay available until you decide to dismiss it.

To keep the Toolbox or any other window fixed in its expanded mode, click its Auto Hide button.

 

Adding Controls

The primary object you will use in your applications is the form. Its main job is to host other controls. Therefore, to use a control in your application, you can select it from the Toolbox and click the desired area on the form. Once added, a control is positioned where your mouse landed. In the same way, you can add other controls as you judge them necessary for your application. Here is an example of a few controls added to a form:

Alternatively, to add a control, you can also double-click it from the Toolbox and it would be added to the top-left section of the form.

If you want to add a certain control many many times, before selecting it on the Toolbox, press and hold Ctrl. Then click it in the Toolbox. This permanently selects the control. Every time you click the form, the control would be added. Once you have added the desired number of this control, on the Toolbox, click the Pointer button to dismiss the control.

Selecting Controls

Before performing any type of configuration on a control, you will first need to select it on the form. Sometimes you will need to select a group of controls.

To select one control on the form, you can simply click it. A control that is selected indicates this by displaying 8 small squares, also called handles, around it. Between these handles, the control is surrounded by a thick dotted rectangle. In the following picture, the selected rectangle displays 8 small squares around its shape:

To select more than one control on the form, click the first. Press and hold either Shift or Ctrl. Then click each of the desired controls. If you click a control that should not be selected, click it again. After selecting the group of control, release either Shift or Ctrl that you were holding. When a group of controls are being selected, the last selected control displays 8 handles too but its handles are dark. In the following picture, three controls are selected:

Another technique you can use to select various controls consists of clicking on an unoccupied area on the form, holding the mouse down, drawing a fake rectangle, and releasing the mouse. Every control touched by the fake rectangle or included in it would be selected.

Moving Controls

One of the operations you will perform during design consists of moving controls around to give them a better location and take advantage of the form's real estate. Various options are available to do this.

To move one control, click and hold the mouse on it, then drag in the desired direction, and release the mouse. Alternatively, click the control to select it. Then, to move it, press one of the arrow keys, either left to move the control left, up to move the control up, right to move the control in the right direction, or down to move the control down.

To move a group of control, select them first. Then click and drag any area in the selection to the desired location. Alternatively, once you have  the controls, you can press one of the arrow keys to move the whole group.

When moving either a control or a group using either the mouse or the keyboard, the control or the group would follow the grids on the form and it can move only one grid mark at a time. This allows you to have a better alignment of controls. If you want to move the control or the group in smaller units than those of the grid, press and hold Ctrl. Then press one of the arrow keys. Once the control or the group is positioned to your liking, release the Ctrl key.

 


Previous Copyright 2003 FunctionX, Inc. Next