Cicode Programming Reference > Cicode Function Categories > Form Functions Introduction > FormComboBox

FormComboBox

Adds a combo box to the current form. A combo box is a form control that allows the operator to type a selection or make a single selection from a text list.

You should call this function only after the FormNew() function and before the FormRead() function. The combo box is added to the form at the specified column and row position with the specified width and height. If more items are placed in the list than the list can display, a scroll bar displays (to scroll to the hidden items).

Use the FormAddList() function to add items for display in the list box. If the form is already displayed, you can use the FormListAddText() and FormListSelectText() functions to add (and highlight) text in the list box.

Syntax

FormComboBox(Col, Row, Width, Height, sBuf [, Mode] )

Col:

The number of the column in which the combo box will be placed. Enter a number from 0 (column 1) to the form width - 1. For example, to place the combo box in column 8, enter 7.

Row:

The number of the row in which the combo box will be placed. Enter a number from 0 (row 1) to the form height - 1. For example, to place the combo box in row 6, enter 5.

Width:

The width of the list box, which should be wide enough to display your widest item. Items wider than the list box are clipped.

Height:

The height of the list box (the number of items that can be seen in the list box without scrolling).

sBuf:

The string buffer in which to store the selected item. The sBuf parameter can also hold the starting selection for the Combo box. For example if you set the sBuf string to "HELLO" before calling FormComboBox, HELLO will be displayed in the box upon opening the form.

Mode:

The mode in which to create the combo box:

0 - Sort the combo box elements alphabetically.

1 - Place elements in combo box in the order they were added.

Default mode is 0.

Return Value

The field handle if the combo box is successfully added, otherwise -1 is returned.

Related Functions

FormNew, FormRead, FormAddList, FormListAddText, FormListSelectText, FormListBox

Example

! Create a form, add combo box and then display the form
! the operator may type in or select one of the items from the list
FUNCTION FnMenu()
STRING sBuf;
FormNew("Select Item",20,6,1);
FormComboBox(2 ,2, 15, 5, sBuf, 1);
FormAddList("Item One");
FormAddList("Item two");
FormAddList("Item three");
FormRead(0);
! sBuf should contain the selected item or entered text
END

See Also

Form Functions