Skip to main content

SelectComboBoxItem

Select the specified combo box item.

void SelectComboBoxItem(int item);
void SelectComboBoxItem(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 combo box, the string should match the value of the combo 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 GetComboBoxItems.

Example

Control setupDialog = FindTopWindow("Page Setup"); // find the top window with the caption "Page Setup"
IList<Control> comboBoxes = setupDialog.FindControls(null, "ComboBox"); // get a list of combo box controls
comboBoxes[0].SelectComboBoxItem(2); // will select the 3rd item in the Combo Box (first item has an ID of 0)
SelectComboBoxItem("Local Harddrive"); // will attempt to match the string value with an item in the Combo Box

Related: