ListBox and ComboBox Controls

Interrogated targets represented by the Studio ListBoxes and ComboBoxes support the general control properties, methods, and events described in General Windows Control Properties, Methods, and Events. In addition, Studio exposes properties, methods, and events specific to these controls. This topic describes the following.

 

Properties

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 the 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 the 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 the ListBox control.)

 

Events

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.

 

Methods

Method

Description

Parameters

Return Type

ClickItem

Applies to the ListBox control. Clicks the item in the control designated by the index parameter.  

Int32 index

Void

ClickItem

Applies to the 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. For more information, see Wildcard Text Parameters.  

String wildcard

Boolean

DeselectItem

Applies to the ListBox for which MultiSelect is enabled. Deselects (removes the highlight) the item designated by the index parameter.  

Int32 index

Void

DeselectItem

Applies to the 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. For more information, see Wildcard Text Parameters.

String wildcard

Boolean

DoubleClickItem

Applies to the ListBox control. Raises the Double-Click event on the item in the control designated by the index parameter.

Int32 index

Void

DoubleClickItem

Applies to the 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. For more information, see  Wildcard Text Parameters.

String wildcard

Boolean

FindItem

Returns the index (Int32) for item designated by the string parameter. Note that wildcards are supported for this method. For more information, see Wildcard Text Parameters.

String wildcard

Int32

IsSelected

Applies to the 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. For more information, see Wildcard Text Parameters.

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.For more information, see Wildcard Text Parameters.

String wildcard

Boolean

 

Populating a ListBox/Combobox

These steps show 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. These steps show how to populate a ComboBox.

  1. Add an event source such as a button to a solution.

  2. Add a data source such as a text box.

  3. Add a combo box.

  4. Add an automation to the project.

  5. Highlight the combo box in Object Explorer and click the Explore Component Properties button.

  6. Highlight the Items property in the Properties tree.

  7. In the Object Inspector, click the Configure Type button to open the Component Configuration window.

  8. Select the Add(Object item) method and drag this method to the automationExecutable logic created within Studio..

  9. Click the Explore Components button to return Object Explorer to the standard control hierarchy view.

  10. Drag the Button.Click event and TextBox.Text property to the automation.

  11. 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.

For more information, see Updating Controls on WinForms.

 

User-Drawn Items

Some list boxes or combo boxes contain user-drawn items. To work with the Items collection from these controls, you must set the UseGDI property on the list box or combo box to True . When set to True, the items can be read and used in a solution. The default is False. For example, here is an example of a list box with user-drawn items.

After interrogating the list box, set the UseGDI property to True.

The result of sending the list box items (DataTable) to a Windows grid is shown here.

 


Privacy | Trademarks | Terms of Use | Feedback

Updated: 18 June 2020

© 2016 - 2020 Pegasystems Inc.  Cambridge, MA All rights reserved.

 

OpenSpan data classification label