wpf-devexpress-dot-xpf-dot-grid-dot-treelistnodeiterator-d69006b8.md
Moves to the next node.
Namespace : DevExpress.Xpf.Grid
Assembly : DevExpress.Xpf.Grid.v25.2.dll
NuGet Package : DevExpress.Wpf.Grid.Core
public bool MoveNext()
Public Function MoveNext As Boolean
| Type | Description |
|---|---|
| Boolean |
true if the current node is not the last node; otherwise, false.
|
Use the MoveNext method to iterate through the nodes. The currently processed node is returned by the TreeListNodeIterator.Current property. Each time the MoveNext method is called, the Node Iterator moves to the next node in the hierarchy and updates the TreeListNodeIterator.Current property. If the current node is the last node, the MoveNext method returns false.
To reset the Node Iterator to its initial state, call the TreeListNodeIterator.Reset method.
This example shows how to traverse through all visible nodes to expand ones that have 4 or more child nodes. Nodes that have less than 4 child nodes are collapsed.
View Example: Iterate Through Nodes With the TreeListNodeIterator
<dxg:GridControl x:Name="grid"
AutoGenerateColumns="AddNew"
EnableSmartColumnsGeneration="True"
Loaded="OnGridLoaded">
<dxg:GridControl.View>
<dxg:TreeListView x:Name="view" AutoWidth="True"
KeyFieldName="ID" ParentFieldName="ParentID"/>
</dxg:GridControl.View>
</dxg:GridControl>
void SmartExpandNodes(int minChildCount) {
TreeListNodeIterator nodeIterator = new TreeListNodeIterator(view.Nodes, true);
while (nodeIterator.MoveNext())
nodeIterator.Current.IsExpanded = nodeIterator.Current.Nodes.Count >= minChildCount;
}
void OnGridLoaded(object sender, RoutedEventArgs e) {
SmartExpandNodes(4);
}
Private Sub SmartExpandNodes(ByVal minChildCount As Integer)
Dim nodeIterator As TreeListNodeIterator = New TreeListNodeIterator(Me.view.Nodes, True)
While nodeIterator.MoveNext()
nodeIterator.Current.IsExpanded = nodeIterator.Current.Nodes.Count >= minChildCount
End While
End Sub
Private Sub OnGridLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
SmartExpandNodes(4)
End Sub
The following code snippets (auto-collected from DevExpress Examples) contain references to the MoveNext() method.
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.
TreeListNodeIterator iterator = new TreeListNodeIterator(nodes);
while(iterator.MoveNext()) {
this.SubscribeObject(iterator.Current.Content);
TreeListNodeIterator nodeIterator = new TreeListNodeIterator(view.Nodes, true);
while (nodeIterator.MoveNext())
nodeIterator.Current.IsExpanded = nodeIterator.Current.Nodes.Count >= minChildCount;
Dim iterator As New TreeListNodeIterator(nodes)
Do While iterator.MoveNext()
Me.SubscribeObject(iterator.Current.Content)
Dim nodeIterator As TreeListNodeIterator = New TreeListNodeIterator(Me.view.Nodes, True)
While nodeIterator.MoveNext()
nodeIterator.Current.IsExpanded = nodeIterator.Current.Nodes.Count >= minChildCount
See Also