windowsforms-devexpress-dot-xtratreelist-dot-treelistmultiselection-dot-set-x28-system-dot-collections-dot-ienumerable-x29.md
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
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public void Set(
IEnumerable nodes
)
<Browsable(False)>
<EditorBrowsable(EditorBrowsableState.Never)>
Public Sub Set(
nodes As IEnumerable
)
| Name | Type | Description |
|---|---|---|
| nodes | IEnumerable |
A group of nodes to select.
|
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.
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);
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