[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Views
   [Collapse]Grid View Data Layout
    [Expand]Columns and Card Fields
    [Expand]Bands
    [Expand]Rows and Cards
    [Collapse]Nodes
      Nodes Overview
      Iterate Through Nodes
      Expand and Collapse Nodes
      Obtain Nodes
      Check Nodes
      Sort Nodes
      Filter Nodes
      Move Nodes
     Data Cells
     Best Fit
     Compact Mode
   [Expand]Binding to Data
   [Expand]Master-Detail Data Representation
   [Expand]Data Editing and Validation
   [Expand]Grouping
   [Expand]Filtering and Searching
   [Expand]Sorting
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus, Navigation, Selection
   [Expand]Drag-and-Drop
   [Expand]Conditional Formatting
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]End-User Interaction
   [Expand]Miscellaneous
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Expand and Collapse Nodes

The TreeListView allows users to expand/collapse parent nodes to show/hide their children:

Tip

Demo: TreeList View

Requires installation of WPF Subscription. Download

Expanded Expand and Collapse Nodes in UI

Users can expand/collapse nodes as follows:

  • Click a node's expand button.
  • Focus a node and press Ctrl + Left / Right.
Note

Expanded Expand and Collapse Nodes in Code

Use the following API to expand/collapse nodes in code:

API Description
TreeListNodeBase.IsExpanded Gets or sets whether the node is expanded.
TreeListView.ExpandNode / TreeListView.CollapseNode Expands/collapses a node.
TreeListView.ChangeNodeExpanded Gets or sets the expanded state of a node.
TreeListView.ExpandToLevel Expands the parent nodes down to the specified nesting level.
TreeListNodeBase.ExpandAll / TreeListNodeBase.CollapseAll Expands/collapses all child nodes within the node.
TreeListView.ExpandAllNodes / TreeListView.CollapseAllNodes Expands/collapses all nodes within the TreeListView.
TreeListView.AutoExpandAllNodes Gets or sets whether all nodes are automatically expanded when the TreeListView is loading.

Before a node is expanded/collapsed, the TreeListView.NodeExpanding / TreeListView.NodeCollapsing event is raised.

After a node is expanded/collapsed, the TreeListView.NodeExpanded / TreeListView.NodeCollapsed event is raised.

Expanded Expand State

Use the following properties to bind node expand states to a property:

Property Description
TreeListView.ExpandStateBinding Gets or sets the binding that determines which nodes are expanded.
TreeListView.ExpandStateFieldName Gets or sets the name of the data source's field that determines which nodes are expanded.
Note

The TreeListView.ExpandStateBinding property takes precedence over the TreeListView.ExpandStateFieldName property.

Expanded Related API

EnableDynamicLoading Property

The TreeListView in hierarchical binding mode creates child nodes dynamically when you expand their parent node.

Set the TreeListView.EnableDynamicLoading property to false to create all nodes at once when the tree is loading.

FetchSublevelChildrenOnExpand Property

The TreeListView in hierarchical binding mode fetches child nodes of sub-level nodes when you expand their parent node.

If the TreeListView.FetchSublevelChildrenOnExpand property is false, all the child nodes display expand buttons (even if they do not have children) after you expand their parent node. The expand button is hidden when you expand a sub-level node that does not contain child nodes.

The TreeListView.HasChildNodesPath property allows you to control expand buttons when sub-level children are not fetched.

ExpandNodesOnFiltering Property

Set the TreeListView.ExpandNodesOnFiltering property to true to expand a node if its child nodes contain the search text.

Tip

Topic: Filter Nodes

Is this topic helpful?​​​​​​​