[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Collapse]Tree List
   [Expand]Product Information
   [Collapse]Feature Center
    [Expand]Data Binding
    [Expand]Data Editing
    [Expand]Data Presentation
    [Expand]Appearances and Look And Feel
    [Collapse]Focus, Selection and Navigation
      Focus and Navigation
      Node Selection
      Breadcrumb Navigation
      Node Checking - Checkboxes and Radio Buttons
      Scrollbar Annotations
     Formatting Cell Values
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End User Capabilities
   [Expand]Member Tables
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Focus and Navigation

You can move focus between nodes using the mouse or keyboard. It's also possible to focus nodes in code. See the following topics, to learn how to do this.

Expanded Focus Movement

The currently focused node is specified by the TreeList.FocusedNode property. You can read its value to access the focused node. Assigning a value to this property results in moving focus to the specified node.

Expanded Example

The following example shows how to move focus to a specific node. To do this, the requried node is assigned to the TreeList.FocusedNode property.

This is not the only way to move focus between nodes. Other methods for moving focus can be divided into two groups. The first group of methods enables you to move focus through nodes that are not hidden within collapsed groups. These are the TreeList.MoveNextVisible, TreeList.MovePrevVisible and TreeList.MoveLastVisible methods. They allow you to move focus to the next, previous and last visible nodes respectively.

The second group of methods allows you to navigate through all nodes regardless of whether they are hidden within collapsed groups or not. These are the TreeList.MoveNext, TreeList.MovePrev and TreeList.MoveLast methods. These methods expand all parent nodes of the node being focused.

Use the TreeList.MoveFirst method to focus the first node within the XtraTreeList. This method doesn't have a pair since the first node is always a root node, and thus, cannot be hidden.

Let's consider an example of using methods from the groups mentioned above. The first screenshot displays the initially focused node.

The following table visually demonstrates the difference between the two groups of methods.

Calling the MovePrevVisible method

Calling the MovePrev method

The MovePrevVisible method focuses the "Sales and Marketing" node - the previous visible node.

The MovePrev method expands the previous visible "Sales and Marketing" node, and focuses its last child - "Marketing".

Let's see one more example of using navigation methods from different groups. The "Consumer Electronics Div." node is initially focused.

The table below illustrates the difference between the TreeList.MoveNext and TreeList.MoveNextVisible methods.

Calling the MoveNextVisible method

Calling the MoveNext method

The MoveNextVisible method moves focus to its next visible node - "Software Products Div.".

The MoveNext method moves focus to the first child of the "Consumer Electronics Div." node.

Expanded Respond to Focus Movement

You can respond to moving focus between nodes by handling the TreeList.BeforeFocusNode, TreeList.AfterFocusNode and TreeList.FocusedNodeChanged events.

The TreeList.BeforeFocusNode event fires before a node is focused. It allows you to identify the previously focused node and the node being focused. You can also cancel the current focus operation by setting the BeforeFocusNodeEventArgs.CanFocus event's parameter to false.

The TreeList.AfterFocusNode and TreeList.FocusedNodeChanged events fire after a node has been focused. The only difference is that the second event provides the previously focused node as its parameter.

Expanded Example

The following example prohibits focusing the first node within the control, by handling the TreeList.BeforeFocusNode event.

Expanded Member Tables

Expanded End-User Capabilities

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