List Boxes and Check-list Boxes

From RAD Studio
Jump to: navigation, search

Go Up to List Controls


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

  1. Within your project, drop a list box component from the Tool palette onto a form.
  2. Size the list box and set its alignment as needed.
  3. Double-click the right side of the Items property or choose the ellipsis button to display the String List Editor.
  4. Use the editor to enter free form text arranged in lines for the contents of the list box.
  5. Then choose OK.

To let users select multiple items in the list box, you can use the ExtendedSelect and MultiSelect properties.

See Also