The TComboBox Component


The TComboBox is a cross between the TEdit and TListBox components. The TComboBox has an edit box that enables the user to enter custom values and a drop-down list that enables the user to select a predefined value.

The two most important properties of the TComboBox component are the Items and Text properties. Like the Items property in the TListBox component, the Items property has a list of items displayed by the control. The only difference is that the items in a TComboBox are displayed only when the user presses the arrow button. The Text property contains the string displayed in the edit box of the TComboBox component.

image from book
Figure 14-15: The Text and Items properties of the TComboBox component

Another often used property of the TComboBox component is the Style property, which modifies both the style and functionality of the combo box. The three standard styles are csDropDown, csDropDownList, and csSimple. The default csDropDown style enables the user to enter custom values in the edit box and select items from the drop-down list, if there are any. The csDropDownList style enables the user to only select predefined items from the drop-down list. This style is very useful when you don't want to write a lot of validation code. The csSimple style enables the user to both enter text into the edit box and select predefined values. The csSimple style also changes the appearance of the TComboBox component by displaying the list box underneath the edit box, as shown in Figure 14-16.

image from book
Figure 14-16: Often used TComboBox styles



Inside Delphi 2006
Inside Delphi 2006 (Wordware Delphi Developers Library)
ISBN: 1598220039
EAN: 2147483647
Year: 2004
Pages: 212
Authors: Ivan Hladni

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net