Back to Devexpress

TreeListNode.Expanded Property

windowsforms-devexpress-dot-xtratreelist-dot-nodes-dot-treelistnode-039874ba.md

latest5.3 KB
Original Source

TreeListNode.Expanded Property

Gets or sets whether the node is expanded.

Namespace : DevExpress.XtraTreeList.Nodes

Assembly : DevExpress.XtraTreeList.v25.2.dll

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

Declaration

csharp
[DefaultValue(false)]
[DXCategory("Behavior")]
public virtual bool Expanded { get; set; }
vb
<DefaultValue(False)>
<DXCategory("Behavior")>
Public Overridable Property Expanded As Boolean

Property Value

TypeDefaultDescription
Booleanfalse

true if the node is expanded; otherwise, false.

|

Remarks

Use the methods below to expand and collapse tree list nodes.

The control’s BeforeExpand, AfterExpand, BeforeCollapse, and AfterCollapse events fire during expand and collapse operations. For example, you can handle the BeforeExpand event to dynamically create child nodes in unbound mode.

Example

The code below changes the first visible node’s expand state.

csharp
using DevExpress.XtraTreeList.Nodes;

TreeListNode node = treeList1.GetNodeByVisibleIndex(0);
node.Expanded = !node.Expanded;
vb
Imports DevExpress.XtraTreeList.Nodes

Dim node = treeList1.GetNodeByVisibleIndex(0)
node.Expanded = Not node.Expanded

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Expanded 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-save-restore-expanded-state-of-nodes/CS/TreeListViewState.cs#L47

csharp
if(node != null)
        node.Expanded = true;
}

winforms-treelist-save-restore-expanded-state-of-nodes/VB/TreeListViewState.vb#L51

vb
If node IsNot Nothing Then
    node.Expanded = True
End If

See Also

BeforeExpand

ExpandToLevel(Int32)

CollapseToLevel(Int32)

TreeListNode Class

TreeListNode Members

DevExpress.XtraTreeList.Nodes Namespace