Controls and Properties

Sanskruti's Avatar author of Controls and Properties
This is an article on Controls and Properties in Visual Basic [VB].
The controls you select for your application's form are important because the controls (also called tools) provide the application interface for your users. Users interact with your application by clicking the controls and entering text in the controls. Placing and sizing controls are perhaps the two most important tasks you can master .After you increase the Form window to a reasonable size, your job is to place controls on the form.

Double-click any control on the Toolbox window to place that control on the Form window. If a control appears in the center of the form already, the new control will be on top of the existing control. You can drag the new control to a different location. The eight sizing handles (the small boxes that appear around a selected control) indicate that the control is selected. If several controls appear on the Form window, the selected controls will display their sizing handles. (Typically, only one control will be selected at any one time but you can select multiple controls by holding the Ctrl key and clicking several controls.)

If you click a toolbox control once, the toolbox highlights the control. If you then move the mouse cursor to the Form window, the mouse cursor turns into a crosshair indicating that you can place the selected control anywhere on the form. Although a control appears in the center of the Form window automatically as soon as you double-click the control, a selected control appears only when you click and drag your mouse crosshair on the Form window. The final control appears when you release the mouse.

Sizing and Moving Controls

You can change the size of only a selected control. The eight sizing handles are the key to resizing the control. You can drag any of the eight sizing handles in any direction to increase or decrease the control's size. Of course, if you placed a control on the form by dragging the control, you won't need to resize the control as often as you would if you double-clicked the toolbox tool to place the control.

You can move a selected control to any area of the Form window by dragging the control with your mouse. After you click to select a control, click the control and hold down the mouse button to drag the control to another part of the Form window.
Sometimes you might want to drag several controls to a new location as a group. For example, perhaps you've placed a set of command buttons at the bottom of a form and after adjusting the Form window's size, you determine that you need to move the buttons down some. Although you can move the command buttons one at a time, you can more quickly select all the command buttons and move them as a group.

Setting Properties

As you add controls to the Form window, the Properties window updates to show the properties for the currently selected control. The selected control is usually the control you last placed on the form. Visual Basic lets you see a control's properties in the Properties window by clicking to select the control or by selecting the control from the Properties window's drop-down list boxThe Left, Top, Height, and Width properties are about the only properties you can set without accessing the Properties window. As you size and move a control into place, Visual Basic updates the Left, Top, Height, and Width properties according to the control's placement on the Form window and the control's size.

As with the form location and size measurements, these properties appear in default (unless you specify a different value in the ScaleMode property). Left indicates how far from the form's left edge the control appears, Top indicates how far from the top of the form the control appears, and the Height and Width properties indicate the control's size.Even the form has properties. Click your Form window and look at the Properties window. The form will be the selected object at the top of the Properties window (Form1 is the default name for an application's initial form).

After you place and size a control, the first property you should modify is the Name property. Although Visual Basic assigns default names to controls when you place them on the Form window, the default names don't indicate the control's true purpose in your application. In addition, the default names don't contain the three-letter prefix that describes the control.Given below is thelist of common prefixes used for control names. When you name your Form window's controls, you'll appreciate later that you took the time to type the three-letter abbreviations at the beginning of the names.

Then you'll be less likely to assign to a text box, a property that belongs to a command button control inside an event procedure. (Such an assignment will cause a runtime error.)The Name property is so important that Visual Basic lists the Name property first (as (Name) inside parentheses) in the Properties window instead of alphabetically in the Properties window, where the other properties reside.

Use these prefix abbreviations for control names.
Prefix  Control 
cbo   -	Combo box
chk   -	Check box
cmd   -	Command button
dir   -	Directory list box
drv   -	Drive list box
fil   -	File list box
fra   -	Frame
frm   -	Form
grd   -	Grid
hsb   -	Horizontal scrollbar
img   -	Image
lbl   -	Label
lin   -	Line
lst   -	List box
mnu   - Menu
ole   -	OLE client
opt   -	Option button
pic   -	Picture box
shp   -	Shape
tmr   -	Timer
txt   -	Text box
vsb   -	Vertical scrollbar
A ToolTip is a pop-up description box that appears when the user rests the mouse pointer over a control.Some property values you set by typing the values directly in the Properties window. For example, to enter a value for a control's ToolTipText property, click once on the Properties window's ToolTipText property and type the ToolTip text
Steel9561's Avatar, Join Date: Apr 2008
Go4Expert Member
Also, I think that when it comes to prefixes, I think that the ones you provided are more accurate for Visual Basic 6 programs and not for VB .NET. I think that on VB .NET even naming conventions changed. For instance, in VB .NET it is more recommendable to use first the name of the button and then the word "Button". For example, if you have a close button you will say something like: "closeButton".

What do you all think about prefixes having changed between VB6 and VB .NET?

Let me know,

Luis Lazo

Last edited by shabbir; 1May2008 at 11:31.. Reason: Confine links to signature
viquas momin's Avatar, Join Date: May 2010
Newbie Member
temme something about toolbox controls