Control - List Box

images\btn_ctrl_listbox.gif List boxes are used to display a list of items from which one or more items can be selected. If there are more items than will fit in the drop-down list, a scroll bar will be automatically added.

 

To create a list box that is a drop down menu style of list box, use a Combo Box control with Style set to DropdownList.

 

To Add a List box to a Form

 

1. Click on the Insert List 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 list boxes desired.

4. Right click onto each list box and choose Properties from the context menu.

5. Set the properties for the list box as desired.

6. Move, resize and align the list 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.

 

 

List box

General

 

MousePointer

The type of mouse pointer displayed when over the list 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.

MultiSelect

Whether or not user can make multiple selections from the list box. NoMultiSelect means none. Simple, means a mouse click or SPACEBAR selects/deselects while arrow keys move focus. Extended adds CTRL and SHIFT click selection in the usual way.

OLEDragMode

DragManual (default) or DragAutomatic. DragManual means the program handles all OLE drag/drop operations, while DragAutomatic means the list box handles all OLE drag/drop operations

OLEDropMode

Set to None (default) if the list box does not accept OLE drops and is to display the No Drop cursor if an OLE drop is attempted. Set to Manual, the list box will trigger OLE drop events, allowing programs to handle the OLE drop operation in code.

Style

Standard or Checkbox. Checkbox adds little boxes that may be checked ON or OFF to select an item in the list.

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 list 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.

Sorted

True or False. True means to sort the list alphabetically.

Columns

An integer number from 0 to n. 0 means no columns and the list box will scroll vertically. 1 to n means up to n columns and the list box will scroll horizontally through snaking columns as the columns are filled in with list items. If originally set non-zero, the number of columns may be changed at run time, but a zero setting at design time cannot be made non-zero at run time and vice versa.

 

 

List

 

List

List items for this list 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 list box's background.

Fore Color

Color to be used for the list 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.