Syntax 3: For TreeView controls
Description
Retrieves the data associated with the specified item.
Applies to
TreeView controls
Syntax
|
1 |
treeviewname.GetItem ( itemhandle, item) |
|
Argument |
Description |
|---|---|
|
treeviewname |
The name of the TreeView control in which you want to |
|
itemhandle |
The handle for the item for which you want to retrieve |
|
item |
A TreeViewItem variable in which you want to store the |
Return value
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 2 3 4 |
treeviewitem tvi This.SetItem(handle, tvi) tvi.OverlayPictureIndex = 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 2 3 4 5 6 7 8 9 10 11 12 13 |
treeviewitem l_tvinew, l_tviold // Get the treeview item that was the old selection tv_list.GetItem(oldhandle, l_tviold) // Get the treeview item that is currently selected tv_list.GetItem(newhandle, l_tvinew) // Print the labels for the two items in the // SingleLineEdit sle_get.Text = "Selection changed from " & + String(l_tviold.Label) + " to " & + String(l_tvinew.Label) |
See also