Skip to main content
A newer version of this page is available. .

TreeListMultiSelection Class

Represents a collection of selected nodes for the Tree List control.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v18.1.dll

Declaration

public class TreeListMultiSelection :
    ICollection<TreeListNode>,
    IEnumerable<TreeListNode>,
    ICollection,
    IEnumerable

The following members accept/return TreeListMultiSelection objects:

Remarks

The TreeListMultiSelection class provides facilities to manipulate selected nodes.

The collection of selected nodes for the Tree List control is supported by the TreeList.Selection property. Using the TreeListMultiSelection class methods you can select or unselect a specific node, unselect all nodes, and access nodes in this collection.

To enable selection of multiple nodes, set the TreeListOptionsSelection.MultiSelect property to true.

At runtime, multiple nodes can be selected by the left mouse button holding the SHIFT or CTRL key. The SHIFT key allows you to select a continuous range of nodes at a specific level. The CTRL key allows you to select or unselect individual nodes.

Important

Instances of this class are not intended to be used as stand-alone objects.

Example

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

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

MultiSelect_Children

using DevExpress.XtraTreeList.Nodes;

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

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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the TreeListMultiSelection class.

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.

Inheritance

Object
TreeListMultiSelection
See Also