Many of the controls require similar properties as forms. The next table lists some common properties that most controls support. All controls have a screen location (indicated by the Left and Top properties) and a size (indicated by the Width and Height properties), and most have foreground and background colors as well as font properties, if the controls display text.
Property | Description |
---|---|
Alignment | Determines whether text on the control, such as a label or command button, is left-justified, centered, or right-justified on the control. |
BackColor | Specifies the color of the control's background, which you select from a palette of colors when you open the property's drop-down list box of colors. |
BorderStyle | Determines whether the control has a border around it. |
Caption | Lists the text displayed on the control. |
Enabled | Set by a drop-down list box, this property is either True if you want the control to respond to the user or False if you want the control not to respond to the user. This property is useful for turning on and off controls when they are and are not available during a program's execution. |
Font | Displays a Font dialog box from which you can set various font properties, such as size and style, for a control's text. |
ForeColor | Specifies the color of the control's foreground, which you select from a palette of colors when you open the property's drop-down list box of colors. |
Height | Specifies the number of twips high the control is. |
Left | Indicates the starting twip from the left edge of the form where the control appears. For a form, the Left property specifies the number of twips from the left edge of the screen. |
MousePointer | Determines the shape of the mouse cursor when the user moves the mouse over the control at runtime. |
Name | Specifies the name of the control. As you saw in yesterday's lesson, the Properties window displays the Name property in parentheses so that it appears first in the list of properties. |
ToolTipText | Holds the text that appears when the user rests the mouse cursor over the control at runtime. |
Top | Is the starting twip from the top edge of the form where the control appears. For a form, the Top property describes the number of twips from the top edge of the screen. |
Visible | Set by a drop-down list box, this property is True if you want the control to be visible on the form or False if you want the control to be hidden from view. |
Width | Specifies the number of twips wide that the control is. |
Some control properties, such as the Alignment property values, may look strange because their drop-down list boxes display numbers to the left of their values. For example, the Alignment property can take on one of these three values: 0 'Left Justify, 1 'Right Justify, and 2 'Center. You can use your mouse to select these values from the list without worrying about the numbers in them, but you can also, after opening the drop-down list box for a property, type the number that corresponds to the value you want to quickly set that value. The numbers also come in handy when you assign property values to controls with code.
Only one control on a form can have the focus at any one time. The first control with the focus is determined by the order in which you placed the controls on the form or, more accurately, the order determined by the creation order of each control on your form. This can be modified using the "Ocx Overview" window.
Not every control can receive focus. Only those controls the user can interact with can receive the focus. For example, a label control cannot receive the focus because the user cannot interact with label controls. The focus, or control focus, is the currently selected control. The control with the focus is indicated by highlighting the control.
Back to: Creating An Application.
{Created by Sjouke Hamstra; Last updated: 16/05/2020 by James Gaite}