Syntax 3 For TreeView controls
Description
Retrieves the data associated with the specified item.
Controls
TreeView controls
Syntax
|
1 |
<span>treeviewname</span><span>.GetItem</span> ( <span>itemhandle, item</span>) |
|
Argument |
Description |
|---|---|
|
treeviewname |
The name of the TreeView control in which |
|
itemhandle |
The handle for the item for which you |
|
item |
A TreeViewItem variable in which you |
Return Values
Integer. Returns 1 if it succeeds and
-1 if an error occurs.
Usage
Use GetItem to retrieve the state information associated with
a specific item in a TreeView (such as label,
handle, or picture index). After you have retrieved the information,
you can use it in your application. To change a property of an item,
call GetItem to assign the item to a TreeViewItem
variable, change its properties, and call SetItem to
copy the changes back to the TreeView.
Examples
This code for the Clicked event gets the clicked
item and changes it overlay picture. The SetItem function
copies the change back to the TreeView:
|
1 |
treeviewitem tvi |
|
1 |
This.SetItem(handle, tvi) |
|
1 |
tvi.OverlayPictureIndex = 1 |
|
1 |
This.SetItem(handle, tvi) |
This example tracks items in the SelectionChanged event. If
there is no prior selection, the value of l_tviold is
zero:
|
1 |
treeviewitem l_tvinew, l_tviold |
|
1 |
|
1 |
// Get the treeview item that was the old selection |
|
1 |
tv_list.<span>GetItem</span>(oldhandle, l_tviold) |
|
1 |
|
1 |
// Get the treeview item that is currently selected |
|
1 |
tv_list.<span>GetItem</span>(newhandle, l_tvinew) |
|
1 |
|
1 |
// Print the labels for the two items in the |
|
1 |
// SingleLineEdit |
|
1 |
sle_get.Text = "Selection changed from " & |
|
1 |
+ String(l_tviold.Label) + " to " & |
|
1 |
+ String(l_tvinew.Label) |