FindItem Function (TreeViewEx)

Class

TreeViewEx.

Action

Returns the index of an item in a tree.

Syntax

iIndex = treeitem.FindItem(sItem)
Variable Description
iIndex The item index. INTEGER.
sItem The text of the item to find in the tree. STRING.

You can identify an item by using a path, the index or a combination of the two. For more information, see Identification of TreeView Items.

To find an item in a multicolumn TreeViewEx you must specify the item text in a column by using a semicolon as a separator. See the example of using a semicolon in Identification of TreeView Items.

Wildcard characters are supported: a question mark (?) to match any single character, and an asterisk (*) to match zero or more characters.

Notes

This functionality is supported only if you are using the Classic Agent.

If the item sItem is not found, FindItem returns zero (0).

Identification of TreeView Items

The following examples show how you can identify unique items within a TreeViewEx class by using a path, the index, or using a combination of the two.

This Specification... Identifies this Item...
"Games" An item "Games" that exists at any level, but which is unique among all currently viewable items in the entire treeview.
"#23" The 23rd currently viewable item in the entire treeview.
24 The 24th currently viewable item in the entire treeview.
"Games/Sub1/Sub2" An item "Sub2" under an item "Sub1" under an item "Games" with unspecified ancestry.
"/Desktop/Applications/Games" A unique item "Games" under a unique item "Applications" under a unique item "Desktop" at the outer level of the treeview.
"/Desktop/#2/#4" The fourth item under the second item under a unique item "Desktop" at the outer level of the treeview.

At the same time, if the tree widget has columns, you can use a semicolon to specify a particular column or columns. The following examples show how to identify items within a JavaSwtTreeView using the text in a column.

This Specification... Identifies this Item...
"Games;Poker;Texas Poker" An item having text "Games" in the first column, "Poker" in the second column and "Texas Poker" in the third column that exists at any level, but which is unique among all currently viewable items in the entire treeview.
"*;*; Gin Rummy" An item "Gin Rummy" in the third column.
"Games/Sub1;*; Poker/*;*Sub2" An item with the text "Sub2" in the third column under an item with the text "Sub1" in the first column and the text "Poker" in the third column under an item with the text "Games" in the first column with unspecified ancestry.