Back to Devexpress

TreeListMultiSelection.Set(IEnumerable) Method

windowsforms-devexpress-dot-xtratreelist-dot-treelistmultiselection-dot-set-x28-system-dot-collections-dot-ienumerable-x29.md

latest2.8 KB
Original Source

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.v25.2.dll

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

Declaration

csharp
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public void Set(
    IEnumerable nodes
)
vb
<Browsable(False)>
<EditorBrowsable(EditorBrowsableState.Never)>
Public Sub Set(
    nodes As IEnumerable
)

Parameters

NameTypeDescription
nodesIEnumerable

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).

csharp
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);
vb
TreeList1.BehaviorOptions = TreeList1.BehaviorOptions Or BehaviorOptionsFlags.MultiSelect
Dim al As New ArrayList()
Dim i As Integer
For i = 0 To TreeList1.Nodes.Count - 1
   Dim en As IEnumerator = TreeList1.Nodes(i).Nodes.GetEnumerator()
   While (en.MoveNext())
      al.Add(en.Current)
   End While
Next
TreeList1.Selection.Set(al)

See Also

TreeListMultiSelection Class

TreeListMultiSelection Members

DevExpress.XtraTreeList Namespace