RAD Studio |  |

Using TDBListBox and TDBComboBox
See Also
Collapse All

When using TDBListBox or TDBComboBox, you must use the String List editor at design time to create the list of items to display. To bring up the String List editor, click the ellipsis button for the Items property in the Object Inspector. Then type in the items that you want to have appear in the list. At runtime, use the methods of the Items property to manipulate its string list.

When a TDBListBox or TDBComboBox control is linked to a field through its DataField property, the field value appears selected in the list. If the current value is not in the list, no item appears selected. However, TDBComboBox displays the current value for the field in its edit box, regardless of whether it appears in the Items list.

For TDBListBox, the Height property determines how many items are visible in the list box at one time. The IntegralHeight property controls how the last item can appear. If IntegralHeight is False (the default), the bottom of the list box is determined by the ItemHeight property, and the bottom item may not be completely displayed. If IntegralHeight is True, the visible bottom item in the list box is fully displayed.

For TDBComboBox, the Style property determines user interaction with the control. By default, Style is csDropDown, meaning a user can enter values from the keyboard, or choose an item from the drop-down list. The following properties determine how the Items list is displayed at runtime:

- Style determines the display style of the component:
- csDropDown (default): Displays a drop-down list with an edit box in which the user can enter text. All items are strings and have the same height.
- csSimple: Combines an edit control with a fixed size list of items that is always displayed. When setting Style to csSimple, be sure to increase the Height property so that the list is displayed.
- csDropDownList: Displays a drop-down list and edit box, but the user cannot enter or change values that are not in the drop-down list at runtime.
- csOwnerDrawFixed and csOwnerDrawVariable: Allows the items list to display values other than strings (for example, bitmaps) or to use different fonts for individual items in the list.
- DropDownCount: the maximum number of items displayed in the list. If the number of Items is greater than DropDownCount, the user can scroll the list. If the number of Items is less than DropDownCount, the list will be just large enough to display all the Items.
- ItemHeight: The height of each item when style is csOwnerDrawFixed.
- Sorted: If True, then the Items list is displayed in alphabetical order.

See Also

Displaying and Editing Data in Lookup List and Combo Boxes

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!