Items Property

Applies to TestComplete 15.20, last modified on January 19, 2022

Provides an interface to items displayed by the component.

Declaration

componentObj.Items
Read-Write Property A TcxRadioGroupItems or TStrings object
componentObj     One of the user forms components or objects listed in the Applies To section  

Applies To

The property applies to the following components and objects:

TcxComboBoxProperties, TcxListBox, TcxRadioGroupProperties

Description

The property’s meaning depends on the object that belongs to the property:

  • The Items property of the TcxListBox component lets you get or set the list of string items displayed by the list box.
  • The Items property of the TcxComboBoxProperties object provides access to the list of items that are displayed in the drop-down window.
  • The Items property of the TcxRadioGroupProperties object provides access to the collection of radio buttons displayed in the radio group.

Property Value

Depending on the object type, the Items property returns one of the following objects:

  • For TcxComboBoxProperties and TcxListBox objects, the Items property returns a TStrings object.
  • For TcxRadioGroupProperties object, the Items property returns a TcxRadioGroupItems object.

Using methods and properties of the returned object, you can add new or delete existing items, change their order, change item text and perform other operations.

Remarks

To specify the component’s items at design time, press the ellipsis button within the property value cell and use the ensuing editor.

Example

The following code snippet demonstrates how you can populate a TcxComboBox component at run time. In this example, the code resides in the OnShow event handler of the form containing the combo box, so that items are added to the combo box when the form is about to be displayed on screen:

JavaScript, JScript

function UserForm1_OnShow(Sender)
{
  // Specify the comma-separated item list
  UserForms.UserForm1.cxComboBox1.Properties.Items.CommaText = "Item1,Item2,Item3,Item4,Item5";

  // -- or

  // Specify the item list separated by new line symbols
  // UserForms.UserForm1.cxComboBox1.Properties.Items.Text = "Item1\r\nItem2\r\nItem3\r\nItem4\r\nItem5";
}

Python

def UserForm1_OnShow(Sender):
  # Specify the comma-separated item list
  UserForms.UserForm1.cxComboBox1.Properties.Items.CommaText = "Item1,Item2,Item3,Item4,Item5"

  # -- or --
  
  # Specify the item list separated by new line symbols
  # UserForms.UserForm1.cxComboBox1.Properties.Items.Text = "Item1\r\nItem2\r\nItem3\r\nItem4\r\nItem5";

VBScript

Sub UserForm1_OnShow(Sender)
  ' Specify the comma-separated item list
  UserForms.UserForm1.cxComboBox1.Properties.Items.CommaText = "Item1,Item2,Item3,Item4,Item5"

  ' -- or

  ' Specify the item list separated by new line symbols
  ' UserForms.UserForm1.cxComboBox1.Properties.Items.Text = _
  '     "Item1" & vbNewLine & "Item2" & vbNewLine & "Item3" & vbNewLine & "Item4" & vbNewLine & "Item5"
End Sub

DelphiScript

procedure UserForm1_OnShow(Sender);
begin
  // Specify the comma-separated item list
  UserForms.UserForm1.cxComboBox1.Properties.Items.CommaText := 'Item1,Item2,Item3,Item4,Item5';

  // -- or

  // Specify the item list separated by new line symbols
  // UserForms.UserForm1.cxComboBox1.Properties.Items.Text :=
  //     'Item1'#13#10'Item2'#13#10'Item3'#13#10'Item4'#13#10'Item5';
end;

C++Script, C#Script

function UserForm1_OnShow(Sender)
{
  // Specify the comma-separated item list
  UserForms["UserForm1"]["cxComboBox1"]["Properties"]["Items"]["CommaText"] = "Item1,Item2,Item3,Item4,Item5";

  // -- or

  // Specify the item list separated by new line symbols
  // UserForms["UserForm1"]["cxComboBox1"]["Properties"]["Items"]["Text"] = "Item1\r\nItem2\r\nItem3\r\nItem4\r\nItem5";
}

See Also

TcxRadioGroupItems Object
TStrings Object
Sorted Property

Highlight search results