Sunday, January 10, 2010

Command Button Tutorial

Learn Basics of VB Command Button

Ok. You have received user input via TextBox, Radio button, check box, Combo box and list box control. Now you want to process the data and store it in the underlying database. So you give Command button to process the data. In business applications, Save, Delete, Update, Exit, Close commands are given using command buttons.

The frequently used property of command button is, Caption property which sets the descriptive text on the command button.

BackColor property sets the background colour of the command button. To enable this property the style property must be set to graphical. Otherwise this property will not work.

Style property Return/sets the appearance of the control, whether standard (standard Windows style) or graphical (with a custom picture).

DisabledPicture Returns/sets a graphic to be displayed when the button is disabled, if style is set to 1.

DownPicture Returns/sets a graphic to be displayed when the button is in the down position, if style is set to 1.

Visible property Returns/sets a value that determines whether an object is visible or hidden.

ToolTipText property Returns/sets the text displayed when the mouse is paused over the control.

TabStop Returns/sets a value indicating whether a user can use the TAB key to give the focus to an object.

Picture Property Returns/sets a graphic to be displayed in a command button, OptionButton or CheckBox control, if style is set to 1.

MaskColor property Returns or sets a color in a button's picture to be a 'mask', if style is set to 1.

SetFocus method is the common method of command button used to set focus on the control.

Click is the common event of command button control. Mouse click or keyboard's enter key fires this event.

GotFocus, LostFocue, KeyPress, KeyDown, KeyUp, MouseDown, MouseUp are some other events supported by Command button.