Item Property (TreeViewItemCollection Objects)

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

Use the Item property to get access to individual items of the tested control. This property only retrieves information about the subitems of the item, to which the TestObj object corresponds.

Declaration

TestObj.Item(Item)

Read-Only Property A DeveloperExpressASPxTreeListItem, FlexTreeItem, GWTTreeItem, InfragisticsWinTreeItem, JTreeItem, JFXTreeViewItem, OracleFormsTreeItem, QtTreeWidgetItem, SyncfusionTreeViewItem, TelerikWebTreeViewItem, Win32TreeViewItem, WPFTreeViewItem, TelerikTreeViewItem or YUI2TreeViewItem object
TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
Item [in]    Required    Variant    

Applies To

The property is applied to the following object:

View Mode

This property is available in the Object Browser panel and in other panels and dialogs in both Basic and Advanced view modes.

Parameters

The property has the following parameter:

Item

Specifies the desired item. The Item parameter can have one of the following values:

  • The item’s index within the collection. Index is zero-based, that is it starts from 0. The index of the last item is Count-1.

  • The item’s caption or caption mask.

    To indicate variable parts of the item caption, you can use the asterisk (*) and question mark (?) wildcards. The asterisk corresponds to a string of any length, the question mark corresponds to any single character. The caption can be case-sensitive or case-insensitive depending on the value of the Use case-sensitive parameters project setting.

  • The path to the item, in case the desired item is a child item of the given collection. Each item in the path can be specified by its caption or index. Indexes must be enclosed in brackets - [ and ]. Individual captions and indexes in the path must be separated with pipeline characters ( | ).

    Note: If the item caption includes a bracket or a pipeline character, address the item by its index or with the question mark wildcard.

Property Value

A DeveloperExpressASPxTreeListItem, FlexTreeItem, GWTTreeItem, InfragisticsWinTreeItem, JTreeItem, JFXTreeViewItem, OracleFormsTreeItem, QtTreeWidgetItem, SyncfusionTreeViewItem, TelerikTreeViewItem, Win32TreeViewItem, WPFTreeViewItem, TelerikTreeViewItem or YUI2TreeViewItem object that provides information about the specified item.

Remarks

If you use Python or DelphiScript, you should enclose the parameter of the Item property in square brackets: Item[Item].

Example

Consider the following simple example that illustrates how to use this property. Suppose we have a tree view control ATreeView1 that has the structure as shown on the image below.

A tree view structure

There are several ways to get data about the item named Item 2.3:

  • Sequentially get data for the parent top level item and then for the desired item:

    JavaScript, JScript

    MyItem = ATreeView1.wItems.Item("TopItem 2").Items.Item("Item 2.3");
    // -- or --
    MyItem = ATreeView1.wItems.Item(1).Items.Item(2);

    Python

    MyItem = ATreeView1.wItems.Item["TopItem 2"].Items.Item["Item 2.3"]
    # -- or --
    MyItem = ATreeView1.wItems.Item[1].Items.Item[2]

    VBScript

    Set MyItem = ATreeView1.wItems.Item("TopItem 2").Items.Item("Item 2.3")
    ' -- or --
    Set MyItem = ATreeView1.wItems.Item(1).Items.Item(2)

    DelphiScript

    MyItem := ATreeView1.wItems.Item('TopItem 2').Items.Item('Item 2.3');
    // -- or --
    MyItem := ATreeView1.wItems.Item(1).Items.Item(2);

    C++Script, C#Script

    MyItem = ATreeView1["wItems"]["Item"]("TopItem 2")["Items"]["Item"]("Item 2.3");
    // -- or --
    MyItem = ATreeView1["wItems"]["Item"](1)["Items"]["Item"](2);

  • Specify the complete path to the desired item:

    JavaScript, JScript

    MyItem = ATreeView1.wItems.Item("TopItem 2|Item 2.3");
    // -- or --
    MyItem = ATreeView1.wItems.Item("[1]|[2]");

    Python

    MyItem = ATreeView1.wItems.Item["TopItem 2|Item 2.3"]
    # -- or --
    MyItem = ATreeView1.wItems.Item["[1]|[2]"]

    VBScript

    Set MyItem = ATreeView1.wItems.Item("TopItem 2|Item 2.3")
    ' -- or --
    Set MyItem = ATreeView1.wItems.Item("[1]|[2]")

    DelphiScript

    MyItem := ATreeView1.wItems.Item('TopItem 2|Item 2.3');
    // -- or --
    MyItem := ATreeView1.wItems.Item('[1]|[2]');

    C++Script, C#Script

    MyItem = ATreeView1["wItems"]["Item"]("TopItem 2|Item 2.3");
    // -- or --
    MyItem = ATreeView1["wItems"]["Item"]("[1]|[2]");

See Also

TreeViewItemCollection Object
Count Property (TreeViewItemCollection Objects)

Highlight search results