ExtendedTreeViewGetEnumerator Method
Namespace: EWSoftware.ListControlsAssembly: EWSoftware.ListControls (in EWSoftware.ListControls.dll) Version: 2023.4.9.0
public IEnumerator GetEnumerator()
Public Function GetEnumerator As IEnumerator
public:
virtual IEnumerator^ GetEnumerator() sealed
abstract GetEnumerator : unit -> IEnumerator
override GetEnumerator : unit -> IEnumerator
IEnumeratorThe enumerator to use
IEnumerableGetEnumerator txtEnumResults.Text = null;
// Use foreach() on the ExtendedTreeView control itself to
// enumerate all of its nodes recursively.
foreach(TreeNode node in tvExtTree)
txtEnumResults.AppendText($"{new String(' ', node.Level * 4)}{node.Text}\r\n");
Dim node As TreeNode
txtEnumResults.Text = Nothing
' Use For Each on the ExtendedTreeView control itself to enumerate all of its nodes recursively
For Each node in tvExtTree
txtEnumResults.AppendText($"{New String(" "C, node.Level * 4)}{node.Text}" & Environment.NewLine)
Next
bool enumerateSiblings = (sender == btnEnumNodeSibs);
TreeNode node, startNode = tvExtTree.SelectedNode;
if(startNode == null)
{
txtEnumResults.Text = "Select a starting node first";
return;
}
txtEnumResults.Text = null;
// For this, we create the enumerator manually and pass it
// the starting node and a flag indicating whether or not
// to enumerate the siblings of the starting node as well.
TreeNodeEnumerator enumerator = new TreeNodeEnumerator(startNode,
enumerateSiblings);
// Call the MoveNext() method to move through each node. Use the
// Current property to access the current node.
while(enumerator.MoveNext())
{
node = enumerator.Current;
txtEnumResults.AppendText($"Manual Enum: {new String(' ', node.Level * 4)}{node.Text}\r\n");
}
txtEnumResults.AppendText("\r\n\r\n");
// We can also use the helper method to simplify it
foreach(TreeNode tn in TreeNodeEnumerator.Enumerate(startNode, enumerateSiblings))
txtEnumResults.AppendText($"Enum Helper: {new String(' ', tn.Level * 4)}{tn.Text}\r\n");
Dim enumerateSiblings As Boolean = False
Dim node As TreeNode
Dim startNode As TreeNode = tvExtTree.SelectedNode
If sender Is btnEnumNodeSibs Then
enumerateSiblings = True
End If
If startNode Is Nothing Then
txtEnumResults.Text = "Select a starting node first"
Return
End If
txtEnumResults.Text = Nothing
' For this, we create the enumerator manually and pass it the starting
' node and a flag indicating whether or not to enumerate the siblings
' of the starting node as well.
Dim enumerator As New TreeNodeEnumerator(startNode, enumerateSiblings)
' Call the MoveNext() method to move through each node. Use the Current
' property to access the current node.
Do While enumerator.MoveNext()
node = enumerator.Current
txtEnumResults.AppendText($"Manual Enum: {New String(" "C, node.Level * 4)}{node.Text}" &
Environment.NewLine)
Loop
txtEnumResults.AppendText(Environment.NewLine & Environment.NewLine)
' We can also use the helper method to simplify it
For Each node In TreeNodeEnumerator.Enumerate(startNode, enumerateSiblings)
txtEnumResults.AppendText($"Enum Helper: {New String(" "C, node.Level * 4)}{node.Text}" &
Environment.NewLine)
Next