"selectedPos"
Returns or sets the number of the option selected in a combo box.
Synopsis
setValue(string shape, "selectedPos", int n);
getValue(string shape, "selectedPos", int &n);
shape.selectedPos(int n);
Parameters
Parameter | Description |
---|---|
shape | Name of the object |
n | Index of the selected item, starting with 1 |
Description
The number of the selected option can be set or read with this attribute (the index starts at 1). If the list does not contain any options, the attribute returns -1.
This function will not trigger the "changed()" script of the combo box.
Example
The following example outputs the text of the selected option provided the list is not empty.
main()
{
shape cb = getShape("COMBO_BOX1");
int idx;
string s;
// Current item
idx = cb.selectedPos();
if(idx! = -1)
s = cb.selectedText();
// Text belonging to this item
else
s = "List empty";
DebugN(s);
}
Assignment
Combo box
See also
"selectedText" , "current index"