Back to Devexpress

TreeListNode.Level Property

windowsforms-devexpress-dot-xtratreelist-dot-nodes-dot-treelistnode-d3afa56d.md

latest3.9 KB
Original Source

TreeListNode.Level Property

Returns the nesting level of a node.

Namespace : DevExpress.XtraTreeList.Nodes

Assembly : DevExpress.XtraTreeList.v25.2.dll

NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList

Declaration

csharp
[Browsable(false)]
[DXCategory("Layout")]
public int Level { get; }
vb
<Browsable(False)>
<DXCategory("Layout")>
Public ReadOnly Property Level As Integer

Property Value

TypeDescription
Int32

The nesting level of a node.

|

Remarks

The nesting level determines how many nodes you must expand to reach the current node from the root. Topmost nodes in the Tree List are referred to as root tree nodes. The Level of root nodes is zero. The Level of root node children is 1 etc.

The following image displays levels with different colors.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Level property.

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.

winforms-treelist-implement-group-level-style-feature/CS/Q220534/Form1.cs#L40

csharp
if (currentNode.HasChildren)
    rects.Add(currentNode.Level, new Rectangle(bounds.Right - viewInfo.RC.LevelWidth, bounds.Y, viewInfo.RC.LevelWidth, bounds.Height));
bounds = new Rectangle(bounds.Location, new Size(bounds.Width - viewInfo.RC.LevelWidth, bounds.Height));

winforms-treelist-show-checkboxes-for-specific-level/CS/WindowsApplication1/Form1.cs#L77

csharp
return true;
    return node.Level == Level;
}

winforms-treelist-implement-group-level-style-feature/VB/Q220534/Form1.vb#L39

vb
If currentNode.HasChildren Then
    rects.Add(currentNode.Level, New Rectangle(bounds.Right - viewInfo.RC.LevelWidth, bounds.Y, viewInfo.RC.LevelWidth, bounds.Height))
End If

winforms-treelist-show-checkboxes-for-specific-level/VB/WindowsApplication1/Form1.vb#L84

vb
If Level = -1 Then Return True
    Return node.Level = Level
End Function

See Also

ExpandToLevel(Int32)

CollapseToLevel(Int32)

TreeListNode Class

TreeListNode Members

DevExpress.XtraTreeList.Nodes Namespace