Skip to main content

TreeListMultiSelection.Set(IEnumerable) Method

Removes all nodes from the collection of selected nodes and then adds a specific group of nodes to the collection.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v23.2.dll

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

Declaration

[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public void Set(
    IEnumerable nodes
)

Parameters

Name Type Description
nodes IEnumerable

A group of nodes to select.

Remarks

The Set method unselects all nodes and then selects the specified group of nodes.

To set selection for only one node you can use another Set method with a TreeListNode object as a parameter.

The Set method is very useful when it is necessary to select a group of nodes at once. For instance, you can create an object of the ArrayList class, add the desired nodes and then call the Set method with the array as a parameter.

Example

The code below selects all nodes located at the second nesting level (root node children).

treeList1.BehaviorOptions |= BehaviorOptionsFlags.MultiSelect;
ArrayList al = new ArrayList();
for (int i = 0; i < treeList1.Nodes.Count; i++) {
   IEnumerator en = treeList1.Nodes[i].Nodes.GetEnumerator();
   while(en.MoveNext())
      al.Add(en.Current);
}
treeList1.Selection.Set(al);
See Also