Back to Devexpress

Obtain Nodes and Their Row Handles

wpf-402463-controls-and-libraries-navigation-controls-treeview-obtain-nodes-and-their-row-handles.md

latest2.9 KB
Original Source

Obtain Nodes and Their Row Handles

  • Nov 24, 2020
  • 2 minutes to read

The TreeViewControl includes multiple methods that allow you to obtain nodes and their row handles. This topic lists and describes these methods.

A row handle is an integer value that identifies a node regardless of whether it is displayed in the TreeViewControl. A visible index is an integer value that identifies only a visible node. If a node is hidden within a collapsed node, its visible index is always -1.

The following images illustrate the difference between row handles and visible indices.

  • All nodes are expanded:

  • One node is collapsed:

Obtain Nodes

MethodDescription
GetNodeByContent(Object)Returns a node with the specified content.
GetNodeByValue(Object)Returns a node with the specified display value.
GetNodeByRowHandle(Int32)Returns a node with the specified handle.
GetNodeByVisibleIndex(Int32)Returns a node with the specified visible index.
CurrentNodeGets or sets the focused node.
SelectedItemsReturns the collection of selected nodes.

Obtain Row Handles

APIDescription
TreeListNodeBase.RowHandleReturns a node’s row handle.
GetSelectedRowHandles()Returns row handles of selected nodes.
GetRowHandleByVisibleIndex(Int32)Returns a node’s row handle by its visible index.
GetRowVisibleIndexByHandle(Int32)Returns a node’s position in the TreeViewControl by its row handle.

Example

The following code sample gets a node with the specified value, obtains the node’s row handle, and expands the specified node.

csharp
void ExpandSpecifiedNode() {
    var node = treeview.GetNodeByValue("Marketing");
    var rowHandle = node.RowHandle;
    treeview.ExpandNode(rowHandle);
}
vb
Private Sub ExpandSpecifiedNode()
    Dim node = treeview.GetNodeByValue("Marketing")
    Dim rowHandle = node.RowHandle
    treeview.ExpandNode(rowHandle)
End Sub