Skip to main content
A newer version of this page is available. .

TreeList.GetVisibleIndexByNode(TreeListNode) Method

Returns the index of the specified node among the visible nodes.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v18.2.dll

Declaration

public int GetVisibleIndexByNode(
    TreeListNode node
)

Parameters

Name Type Description
node TreeListNode

The TreeListNode object representing the node whose visible index is obtained.

Returns

Type Description
Int32

An integer value specifying the position of the specified node among the visible nodes.

Remarks

A node is implied invisible if it is a child of a collapsed node. The GetVisibleIndexByNode returns a zero or a greater value when the node is out of the Tree List’s viewable area due to the current scrolling position (see the TreeList.TopVisibleNodeIndex property). This method returns -1 in the cases listed below:

  • the specified node is null (Nothing in Visual Basic);
  • the specified node is a child of a collapsed node.

Example

The sample code below demonstrates how to determine whether a user sees a given node within the Tree List’s scrollable area. The IsNodeVisibleOnScreen method returns false if the node is invisible or only partially visible at the bottom of the Tree List control.

private bool IsNodeVisibleOnScreen(DevExpress.XtraTreeList.Nodes.TreeListNode node) {
   DevExpress.XtraTreeList.TreeList tree = node.TreeList;
   int visibleIndex = tree.GetVisibleIndexByNode(node);
   return visibleIndex >= tree.TopVisibleNodeIndex && visibleIndex < 
     tree.TopVisibleNodeIndex + tree.ViewInfo.VisibleRowCount;
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetVisibleIndexByNode(TreeListNode) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also