Syntax 4 For TreeView controls
Description
Find an item based on its position in a TreeView control.
Controls
TreeView controls
Syntax
|
1 |
<span>treeviewname</span><span>.FindItem</span> ( <span>navigationcode, itemhandle</span> ) |
|
Argument |
Description |
|---|---|
|
treeviewname |
The name of the TreeView control in which |
|
navigationcode |
A value of the TreeNavigation enumerated |
|
itemhandle |
A long for the handle of an item related |
Return Values
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 |
|
NextTreeItem! |
The sibling after itemhandle. |
|
PreviousTreeItem! |
The sibling before itemhandle. |
|
ParentTreeItem! |
The parent of itemhandle. |
|
ChildTreeItem! |
The first child of itemhandle. |
|
FirstVisibleTreeItem! |
The first item visible in the control, |
|
NextVisibleTreeItem! |
The next expanded item after itemhandle, |
|
PreviousVisibleTreeItem! |
The next expanded item before itemhandle, |
|
CurrentTreeItem! |
The selected item. Returns -1 if the |
|
DropHighlightTreeItem! |
The item whose DropHighlighted property |
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 |
long ll_tvi |
|
1 |
ll_tvi = tv_list.<span>FindItem</span>(CurrentTreeItem!, 0) |
This example finds the first item on the first level
of a TreeView control:
|
1 |
long ll_tvi |
|
1 |
ll_tvi = tv_list.<span>FindItem</span>(RootTreeItem!, 0) |