A newer version of this page is available. Switch to the current version.

TreeList.Selection Property

Gets the collection of selected nodes.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v19.2.dll


public TreeListMultiSelection Selection { get; }
Public ReadOnly Property Selection As TreeListMultiSelection

Property Value

Type Description

A TreeListMultiSelection instance containing selected nodes.


When a user navigates through the TreeList control, the TreeList.Selection collection contains a selected node. If the TreeListOptionsSelection.MultiSelect option is active and miltiple nodes are selected, the TreeList.Selection collection contains all selected nodes.

To enumerate elements of the collection, you can use the foreach (For Each in Visual Basic) statement, as the following code snippet demonstrates.

string columnName = "DEPARTMENT";
int i = 0;
foreach (DevExpress.XtraTreeList.Nodes.TreeListNode treeListNode in treeList1.Selection) {
    //Set a new value in the Department column for each selected node.
    treeListNode.SetValue(columnName, "Department" + i++.ToString());


The following code shows how to select children of a specific node. In the example, nodes are selected via the TreeListMultiSelection.Set method of the TreeList.Selection object.

The image below shows the result of selecting a Sales and Marketing node's children.


using DevExpress.XtraTreeList.Nodes;

TreeListNode node = treeList1.FindNodeByFieldValue("Department", "Sales and Marketing");
if (node != null) {
    ArrayList selectedNodes = new ArrayList();
    selectChildren(node, selectedNodes);

void selectChildren(TreeListNode parent, ArrayList selectedNodes) {
   IEnumerator en = parent.Nodes.GetEnumerator();
   TreeListNode child;
   while(en.MoveNext()) {
      child = (TreeListNode)en.Current;
      if(child.HasChildren) selectChildren(child, selectedNodes);
See Also