Combo box control

<< Click to Display Table of Contents >>

Manual > Control Reference > Basics >

Combo box control


Combo box control (ComboBox)

 

 

A combo box is an edit box that allows you to select from a list of text.

 

cr_0053

 

 

Basic functions of a combo box

 

A combo box is a control that combines the functions of an edit box and a list box. Pressing the button on the right side of the edit box opens the list box. When you select a line from the list box, the text content is copied to the edit box.

 

1) Normal state

 

cr_0054

 

 

2) List box open

 

cr_0055

 

 

 

Combo Box Type

 

There are two types of combo boxes:

 

- Drop-down combo box

- Drop-down list combo box

 

You can select these using the ComboType property. Drop-down combo boxes allow you to enter text directly, whereas drop-down list combo boxes do not allow you to enter text.

Both types allow you to select from a text list. Below are examples of each type.

 

cr_0056

 

 

 

About text lists

 

There are three ways to set a text list in Combo box control.

 

1) Set it in the TextList property in advance.

2) Add one line at a time using the AddText method.

3) Set them all at once using the SetTextList method.

 

The above steps are the same as for list boxes. For details, please refer to List Boxes.

 


hint

A combo box is a control that combines the functions of a list box and an edit box. The combo box has the same methods as List box control.


 

 

 

About text list selection

 

List box control allows you to select one from a multi-line text list. The selected line is copied into the edit box.

 

1) When an operator changes the row selection, the OnSelectChanged event is called. In the following sample, the OnSelectChanged event is used to display the index and text of the currently selected row in an edit box.

 

cr_0057

 

 

 

event OnSelectChanged(index,text)
{
 parent.Label.Text = text;
}

 

 

2) The index of the currently selected row (row number starting from 0) can be obtained with the SelectIndex property. By output binding to SelectIndex (e.g. OUT : $D0), the currently selected index will be output to a tag in real time. In the sample below, the $D0 tag is bound to the SelectIndex property. When the top row is selected, $D0 will be 0. Each time you move to the next row, the value of $D0 will be 1, 2, 3, etc.

 

cr_0058

 

3) By input binding (e.g. IN : $D0) to the SelectIndex property, you can change the selected row in real time according to the tag value.

 

4) To obtain the content (text) of the currently selected row, use the Text property.