Skip to main content

SelectListBoxItem

Select the specified combo box item.

void SelectListBoxItem(int item);

void SelectListBoxItem(string item);

Parameters

item: Either an integer or a string value can be passed as parameter—the integer specifies the zero-based index of the string to select in the list box, the string should match the value of the list box item value.

Return Value

None

Remarks

The control does not raise an error if the selected item does not exist.

To check if the required item, or number of items exist in the listbox you should first call GetListBoxItems.

Example

AutomationControl dialog = MyControl.FindControl("My Dialog"); // find the child control the caption "My Dialog"
AutomationControl listBox = dialog.FindControl("myListBox", "ListBox"); // get the listbox item named "myListBox"
listBox.SelectListBoxItem(2); // will select the 3rd item in the List Box (first item has an ID of 0)
listBox.SelectListBoxItem("List Box Item"); // will attempt to match the string value with an item in the list box

Related: