Link to OpenSpan Help Home
ListBox and ComboBox Controls
Interrogated targets represented by the OpenSpan ListBoxes and ComboBoxes support the general control properties, methods and events described in the General Windows Control Properties Methods Events topic.
In addition, OpenSpan exposes properties, methods, and events specific to these controls. This section describes:
Property |
Description |
Count |
Gets the number of items in the Listbox/ComboBox. (Int32 type) |
DataTable |
Gets a dataset containing the items from the control along with assigned index values. |
Items |
Gets the collection of items (Obj[]) from the control. |
MultSelect |
Gets a value (Boolean) indicating whether multiple items in the control can be selected. A value of True indicates that multiple items can be selected. (Applies to ListBox control.) |
SelectedIndex |
Gets the value of the index for the selected item. If no item is selected, the value returned is -1. |
SelectedIndices |
Applies to ListBox controls for which MultiSelect is enables. Gets a list of the index values of the selected items. (Int32[] type) (Applies to ListBox control.) |
SelectedItem |
Gets the selected item. If no item is selected, the value returned is null. |
SelectedItems |
Applies to ListBox controls for which MultiSelect is enables. Gets a list of the selected items. (String[] type) (Applies to ListBox control.) |
Events |
Description |
SelectedIndexChanged |
Occurs when the SelectedIndex property has changed (i.e., a different item is selected). |
Updated |
Occurs when items are added or removed from the control. |
Method |
Description |
Parameters |
Return Type |
ClickItem |
Applies to ListBox control. Clicks the item in the control designated by the index parameter. |
Int32 index |
Void |
ClickItem |
Applies to ListBox control. Raises the Click event on the item in the control designated by the string input. Returns a True value if the string wildcard matched a control item. Note that wildcards are supported for this method. See the Wildcard Text Parameters topic for more information. |
String wildcard |
Boolean |
DeselectItem |
Applies to ListBox for which MultiSelect is enabled. Deselects (removes the highlight) the item designated by the index parameter. |
Int32 index |
Void |
DeselectItem |
Applies to ListBox controls for which MultiSelect is enabled. Deselects (removes the highlight) the item designated by the string input. Returns a True value if the string wildcard matched a control item. Note that wildcards are supported for this method. See the Wildcard Text Parameters topic for more information. |
String wildcard |
Boolean |
DoubleClickItem |
Applies to ListBox control. Raises the Double-Click event on the item in the control designated by the index parameter. |
Int32 index |
Void |
DoubleClickItem |
Applies to ListBox control. Raises the Double-Click event on the item in the control designated by the string input. Returns a True value if the string wildcard matched a control item. Note that wildcards are supported for this method. See the Wildcard Text Parameters topic for more information. |
String wildcard |
Boolean |
FindItem |
Returns the index (Int32) for item designated by the string parameter. Note that wildcards are supported for this method. See the Wildcard Text Parameters topic for more information. |
String wildcard |
Int32 |
IsSelected |
Applies to ListBox control. Returns a True value if the item designated by the string parameter is currently selected in the control, otherwise returns False. Note that wildcards are supported for this method. See the Wildcard Text Parameters topic for more information. |
String wildcard |
Boolean |
SelectItem |
Selects (highlights) the item designated by the index parameter. |
Int32 index |
Void |
SelectItem |
Selects (highlights) the item designated by the string parameter. Returns a True value if the string wildcard matched a control item. Note that wildcards are supported for this method. See the Wildcard Text Parameters topic for more information. |
String wildcard |
Boolean |
The following steps illustrate how to work with inherited properties and methods to populate a ComboBox in a project. The ComboBox requires a list of items entered manually through the Items property Collection String Editor dialog or dynamically by using ComboBox Items.Add method. The following steps illustrate how to populate a ComboBox:
Add an even
source such as a Button to a solution.Add a data source such as a TextBox.
Add a ComboBox.
Add an automation to the project.
Highlight the ComboBox in the Object Explorer and click the Explore Component Properties button.
Highlight the Items property in the Properties tree.
In the Object Inspector, click the Configure Type button to open the Component Configuration dialog.
Select the Add(Object item) method and drag this method to the automation.
Click the Explore Components button to return the Object Explorer to the standard control hierarchy view.
Drag the Button.Click event and TextBox.Text property to the automation.
Connect the components as follows:
Note: The Text property will not return anything for Common List Controls as these controls do not have a Text property.
See the Updating Controls on WinForms for recommendations on how to update/populate Windows controls.
Some ListBoxes or ComboBoxes contain user-drawn items. In order to work with the Items collection from these controls, you must set the UseGDI property on the ListBox or ComboBox to True (the default is False). When set to True, the items can be read and used in a solution. For example, the following is an example of a ListBox with own-drawn items:
After interrogating the ListBox, set the UseGDI property to True:
The result of sending the ListBox items (DataTable) to a Windows Grid is the following: