Syntax 4: For TreeView controls
Description
Find an item based on its position in a TreeView control.
Applies to
TreeView controls
Syntax
|
1 |
treeviewname.FindItem ( navigationcode, itemhandle ) |
|
Argument |
Description |
|---|---|
|
treeviewname |
The name of the TreeView control in which you want to |
|
navigationcode |
A value of the TreeNavigation enumerated datatype |
|
itemhandle |
A long for the handle of an item related via |
Return value
Long.
Returns the item handle if it succeeds and -1 if an error
occurs.
Usage
FindItem does not select the item it finds. You must use the
item’s selected property in conjunction with FindItem to select the
result of the FindItem search.
FindItem never finds a collapsed item, except when looking for
ChildTreeItem!, which causes an item to expand. CurrentItem! is not
changed until after the clicked event occurs. To return the correct
handle for the current item when the user clicks it, create a custom
event to return the handle and post it in the clicked event.
If navigationcode is RootTreeItem!, FirstVisibleTreeItem!,
CurrentTreeItem!, or DropHighlightTreeItem!, set itemhandle to 0.
The following table shows valid values for the navigationcode
argument.
|
Navigationcode value |
What FindItem finds |
|---|---|
|
RootTreeItem! |
The first item at level 1. Returns -1 if no items |
|
NextTreeItem! |
The sibling after itemhandle. A sibling is an item |
|
PreviousTreeItem! |
The sibling before itemhandle. Returns -1 if there |
|
ParentTreeItem! |
The parent of itemhandle. Returns -1 if the item is |
|
ChildTreeItem! |
The first child of itemhandle. If the item is |
|
FirstVisibleTreeItem! |
The first item visible in the control, regardless |
|
NextVisibleTreeItem! |
The next expanded item after itemhandle, regardless To scroll to an item that is beyond |
|
PreviousVisibleTreeItem! |
The next expanded item before itemhandle, |
|
CurrentTreeItem! |
The selected item. Returns -1 if the control never |
|
DropHighlightTreeItem! |
The item whose DropHighlighted property was most |
Examples
To return the correct handle when the current item is clicked,
place this code in a custom event that is posted in the item’s clicked
event:
|
1 2 |
long ll_tvi ll_tvi = tv_list.FindItem(CurrentTreeItem!, 0) |
This example finds the first item on the first level of a TreeView
control:
|
1 2 |
long ll_tvi ll_tvi = tv_list.FindItem(RootTreeItem!, 0) |
See also