Combo boxes combine the capabilities of a text box control and a list box control. Combo boxes allow the user to either enter text into the box or to choose one or more items from a list. If there are more items than will fit in the drop-down list, a scroll bar will be automatically added.
When a DropdownList Style is selected, the combo box becomes a list box that has a dropdown menu without the "combo" text box.
To Add a Combo box to a Form
1. Click on the Insert Combo box button in the Tools toolbar.
2. Click and drag the location and size where it is to be created in the form.
3. Continue to create any additional combo boxes desired.
4. Right click onto each combo box and choose Properties from the context menu.
5. Set the properties for the combo box as desired.
6. Move, resize and align the combo box as desired.
Properties normally both return and set that particular property. The easiest way to edit properties is through the context menu's properties dialog for that control.
Some attributes of controls, such as their size or position are properties not of the control but of the container for the control, in this case the Form itself. To change the size or position of controls we can simply click on them and resize or drag them to a new position.
Keep in mind that programs can change the properties of controls at run time. Although this documentation is written as though the properties are set at design time using the Properties dialog for this control, there are many situations in which program code will be used to change a control's properties at run time.
Note: All properties and controls in the Tools toolbar are prefaced with "wl" to indicate they are the windowless lightweight versions of the controls and properties settings. The "wl" prefix is suppressed in the documentation below to enhance legibility.
Properties
In addition to the properties listed below, a Control tab provides access to certain frequently used form properties for this control. See the Form Properties topic for information on those properties.
|
|
Combo box |
|
General |
|
|
Text |
The initial text for the combo box. |
|
MousePointer |
The type of mouse pointer displayed when over the combo box. Choose from 16 different types plus a custom pointer |
|
Appearance |
3D or Flat. 3D is the standard Windows look. Flat results in a rectangular square of background color with a foreground color border. |
|
OLEDragMode |
DragManual (default) or DragAutomatic. DragManual means the program handles all OLE drag/drop operations, while DragAutomatic means the combo box handles all OLE drag/drop operations |
|
OLEDropMode |
Set to None (default) if the combo box does not accept OLE drops and is to display the No Drop cursor if an OLE drop is attempted. Set to Manual, the combo box will trigger OLE drop events, allowing programs to handle the OLE drop operation in code. |
|
Style |
DropdownCombo: classic Windows combo box. SimpleCombo: a text box and a list that does not drop down. Must increase the height to see the list after creating the box. DropdownList: just the dropdown list portion without the editable text box. |
|
Enabled |
True or False. True means the object can respond to user-generated events, false prevents it from responding. We can disable a control like a combo box if we wish it to simply display information in a read-only way. |
|
Integral Height |
True by default, so list resizes to show only complete items. False allows list size so partial items are visible. |
|
Locked |
True or False. True means the user can scroll and highlight the text in the box but cannot change it. The program can change the text by modifying the text box's Text property. False (default) means users can edit the text in the box. |
|
Sorted |
True or False. True means to sort the list alphabetically. |
|
|
|
|
List |
|
|
List |
List items for this combo box. Add an item by entering it and then pressing CTRL-ENTER to move focus to another line. Press Apply. |
|
ItemData |
After adding a list item in the List pane and pressing Apply, a 0 value by default will be added to the ItemData pane for that item. Change this to whatever value is desired. |
|
|
|
|
Color |
|
|
Back Color |
Color to be used for the combo box's background. |
|
Fore Color |
Color to be used for the combo box's foreground, the color of the text caption. |
|
Color Set |
Choose from Standard Colors (standard Windows non-dithered colors) or Windows System Colors. The latter will be defined by the user's Control Panel settings and is normally the setting used so that the form changes appearance like the rest of Windows if the Control Panel settings are changed. |
|
Color Palette |
Displays available colors. Click on the property to be changed to highlight it in the Properties pane, click on the desired color in the Color Palette pane and then press Apply. |
|
Edit Custom Color |
Change the custom color presented in the Color Palette when the Color Set is set to Windows System Colors. |
|
|
|
|
Font |
|
|
Properties |
Font properties that may be changes. |
|
Font |
Choose a font installed on this system. It's wise to choose standard Windows fonts such as MS Sans Serif that are universally available. |
|
Size |
Size of font, in points. |
|
Effects |
Bold, Italic, Underline or Strikeout. |
|
Sample Text |
A preview of the selected settings. |