Skip to main content

GetListBoxItems

Return a list of items in a list box Control.

IList<string> GetListBoxItems();

Parameters

None

Return Value

A list of items in the listbox.

Example

AutomationControl dialog = FindTopAutomationWindow("My Dialog"); // find the top window with the caption "My Dialog"
AutomationControl listBox = dialog.FindControl("myListBox", "ListBox"); // get the listbox item named "myListBox"
IList<string> listBoxItems = listBox.GetListBoxItems();

foreach(string item in listBoxItems)
{
WriteMessage("item=" + item);
}

listBox.SelectListBoxItem("cheese"); // select a listbox item

Related: