TreeList.GetVisibleIndexByNode(TreeListNode) Method

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

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v20.1.dll

Declaration

public int GetVisibleIndexByNode(
    TreeListNode node
)
Public Function GetVisibleIndexByNode(
    node As TreeListNode
) As Integer

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.

Examples

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;
}
See Also