Important properties of the Tcombobox component
Charcase--------This property to set the case of text within the edit box
Dropdowncount---This property is used to set the number of items that can be displayed without a scroll bar when the user pulls down a combo box
Droppeddown-----If the combo box is currently pulled down, this property returns True
ItemHeight------This property to set the height of the item
ItemIndex-------This property returns the ordinal of the item selected in the combo box
Items-----------All items in a combo box can be accessed by this property
MaxLength-------This property is used to set the maximum number of characters a user can enter in a combo box, and 0 represents unrestricted
SelLength-------This property is the number of characters that the user selects in the edit box
SelStart--------This property is the starting point that the user selects in the edit box
SelText---------This property is the text that the user selects in the edit box
Sorted----------items in a combo box are sorted alphabetically
Text------------This property is used to set or return a display on a combo box
Style-----------This property to set the style of the combo box
(1) Charcase property
This property is used to set the case of the text in the edit box, which has 3 values for the user to select.
. Eclowercase: This value causes the Tcombobox component to display all letters in lowercase.
. Ecnormal: This value causes the Tcombobox component to display letters as-is, mixed in case.
. Ecuppercase: This value causes the Tcombobox component to display all letters in uppercase.
(2) Dropdowncount property
By using the property Dropdowncount, you can change the list box to display the number of entries, the default value is 8. When the entry in the list box is greater than Dropdowncount, a scroll bar automatically appears to the right of the list box. When the entry in the list box is less than Dropdowncount, the height of the list box automatically adjusts to show all entries.
(3) ItemHeight property
This property is used to set the height of the item, its value is affected by the style property, and the ItemHeight property only works if the style property is Csownerdrawfixed or sownerdrawvariable.
(4) ItemIndex property
The ItemIndex property returns the ordinal of the item selected in the combo box, or you can change the selected item of the Tcombobox component with this property. This property is often used to get the selection ordinal when writing code. -1 means no item is selected.
(5) The Items property
The Items property can be accessed on the options in the combo box. This property contains several methods and properties, the common properties and methods are as follows.
. Append----------Method You can add an option to the combo box.
. The clear-----------method clears all the options in the combo box.
. The Count-----------property to get the number of options in the combo box.
. The Delete----------method removes the option to specify the ordinal.
. IndexOf---------property to get the options for the specified content.
. Strings---------property to get the option content for the specified ordinal.
. The Text------------property to get all the contents of the selected item in the combo box.
. The valuefromindex--property can get the option content for the specified ordinal.
the properties and methods above can be referenced in the following way:
Tcomboboxname.items. Method (or property)
For example, to add an option dynamically in ComboBox1, you can take advantage of the Items.Add method:
COMBOBOX1.ITEMS.ADD (' Add a new option ');
Instead of removing the option ItemIndex to 1, you can take advantage of the Items.delete method:
ComboBox1.Items.Delete (1);
An Tstringlist class is often used in the Items property, and the properties and methods of the Tstringlist class are exactly the same as the properties of items, although the
Tstringlist class must first be established with the Create method before it can be manipulated. For example, you can use the following method to edit the items property of the Tcombobox component.
var
s:tstringlist;
Begin
S:=tstringlist.create;
S.add (' 1th ');
S.add (' 2nd ');
S.add (' 3rd ');
S.add (' 4th ');
S.add (' 5th ');
Combobox1.items:=s;
End
(6) SelLength property
This property is the number of characters that the user selects in the edit box, and its value is affected by the style property, and the value of the SelLength property is correct only if the Style property is evaluated as Csdropdown or cssimple.
(7) SelStart property
This property is the starting position that the user selects in the edit box, and its value is affected by the style property only if the Style property is Csdropdown or
Cssimple, the value of the SelStart property is not 0, and the other value of the Style property makes the value of the SelStart property 0.
(8) SelText property
This property is the text that the user selects in the edit box, and its value is affected by the style property, and the value of the SelText property is not likely to be empty unless the style property is evaluated as Csdropdown or cssimple. The other values of the Style property leave the value of the SelStart property empty.
(9) The items in the sorted properties
combo box are sorted alphabetically from small to large. When the items within the Tcombobox component are designed, the sorted property is set to True, the items within the combo box are sorted, and even if the sorted property is set to False, the items in the combo box are displayed in sorted order.
(ten) style property
The settings of the Style property reflect the 5 types of drop-down list components, and the values and functions are as follows.
. Csdropdown can be entered in the edit box of the combo box, and the drop-down list box is a set of strings with equal height.
. Csdropdownlist is read-only in the edit box of the combo box, and the contents of the edit box can only be selected from the list box.
. Cssimple is displayed in only one edit box, you can enter a string in the edit box, or you can change the contents of the edit box by the up and DOWN ARROW keys. The
. Csownerdrawfixed consists of a list box with a read-only edit box and an entry height equal to the item in the combo box, and the height of the entry is determined by the property itemheight.
. csownerdrawvariable in a combo box consists of a read-only edit box and a list box, and the entry height can be different.
3, important events for Tcombobox components
Tcombobox components The most common event is the onchange event. The onchange event is triggered when the user selects an item from the drop-down list in the combo box, or if the character is typed directly in the Edit box section. Access the Text property to know the latest content in the edit box. The Ondropdown event is triggered when the user pulls down the combo box. The
onchange events and Ondropdown events are the most common.
4, Tcombobox components Important method
Clear---------This method empties the entire combo box
SelectAll-----This method is used to select all the text in the edit box
(1) Clear method
This method clears all the contents of the combo box. For example, to clear the contents of ComboBox1, you can write:
Combobox1.clear;
(2) SelectAll method
This method is used to check all text in the edit box, which is affected by the style property, and the SelectAll method only works if the style property is Csdropdown or Cssimple.
Important properties of the Tcombobox component