List boxes (TListBox) and check-list boxes display lists from which users can select one or more choices from a list of possible options. The choices are represented using text, graphics, or both.
- Items uses a TStrings object to fill the control with values.
- ItemIndex indicates which item in the list is selected.
- MultiSelect specifies whether a user can select more than one item at a time.
- Sorted determines whether the list is arranged alphabetically.
- Columns specifies the number of columns in the list control.
- IntegralHeight specifies whether the list box shows only entries that fit completely in the vertical space (VCL only).
- ItemHeight specifies the height of each item in pixels. The Style property can cause ItemHeight to be ignored.
- The Style property determines how a list control displays its items. By default, items are displayed as strings. By changing the value of Style, you can create owner-draw list boxes that display items graphically or in varying heights. For information on owner-draw controls, see Adding Graphics to Controls.
To create a simple list box
- Within your project, drop a list box component from the Tool palette onto a form.
- Size the list box and set its alignment as needed.
- Double-click the right side of the Items property or choose the ellipsis button to display the String List Editor.
- Use the editor to enter free form text arranged in lines for the contents of the list box.
- Then choose OK.
To let users select multiple items in the list box, you can use the ExtendedSelect