2: Add Controls
Up
Note: when you create a new project in Visual Basic, be sure to select 'Windows Application' as the desired project type.

Hundreds of different controls are available in the Toolbox and they have been grouped into categories such as common controls, components, containers etc. Most of the controls that we will use are in the common controls group so keep that group open. By pointing at any control you can see a brief description of that control's function.

 

As mentioned, the user interface is ‘drawn’ in the Windows Form window.  There are two ways to place controls on a form:

1.     Double-click the control in the toolbox and it is created with a default size on the form.  You can then move it or resize it.

2.     Click the control in the toolbox, then move the mouse pointer to the form window.  The cursor changes to a crosshair.  Place the crosshair at the upper left corner of where you want the control to be, press the left mouse button and hold it down while dragging the cursor toward the lower right corner.  When you release the mouse button, the control is drawn.

·       To move a control you have drawn, click the object in the form window and drag it to the new location.  Release the mouse button.

·       To resize a control, click the object so that its select and sizing handles appear.  Use these handles to resize the object.  Some controls, such as labels and textboxes, do not necessarily have handles in every corner.

What does each control do? A brief description of some controls follows but not all the controls will be explained here since we will not have time to learn them all. Don't forget though that by pointing at any control in the toolbox you can see a brief description of that control's function. Remember also that the heart of VB programming is writing code, not creating controls.

The Pointer Tool is not used to make controls, but only to select them, move them or resize them. Using the pointer tool, a single control can be selected by clicking it or multiple controls can be selected simultaneously by dragging a selection rectangle around them all. Multiple controls can also be selected simultaneously by holding down the Shift key while you click additional controls.

The PictureBox control can contain various types of image. The PictureBox control is more powerful than the Image control (it allows images to be resized, for example) but the Image control gives smoother animations

The Label control is used for text output (display) only - the user of your program will not be able to type into any label.

The TextBox control is used for both text input and text output.

The Button control is used to trigger any sequence of actions, known as a 'procedure' or 'subroutine'.

  The CheckBox control is used to allow the user to select items that are independent and thus NOT mutually exclusive. For example, check boxes could be used to allow the user to turn on bold, italic or underline styles for some text - it should be possible to turn on these styles in any combination.

The RadioButton control is used for options that are mutually exclusive, since only one radio button can be selected at any one time (clicking an radio button causes other option buttons to become unselected. Radio buttons could be used, for example, to align some text left, center or right. Since the text can only have ONE of these alignments at any given time, radio buttons rather than check boxes should be used for the selection.

Note: this control is not available in the 'Common Controls' group but can be found in the 'Windows Forms' group or the 'Components' group. The Timer control acts like an alarm clock - it can be set to go off at regular intervals such as every 2000 milliseconds (2 seconds) and when it 'goes off' it can trigger a sequence of actions (a 'procedure'). The Timer control can be placed anywhere on the form for it will be invisible to the user.

Hit Counter since February 13, 2001.

Previous Up Next