I am looking for a quicker way to get a list of Checked Nodes.
Right now I am using a For Each Node As UltraTreeNode in TreeNodeCollection
But if there are a thousand nodes in the tree this takes a long time. Loop after loop if each node has children.
I have 2 states a single Check tree where a checked node does not effect the parent and a TriState tree.
Here is my current code:
(This takes in a collection and loops through,
CurrentIdList is a list of Checked Id's that has been passed in, if a node exists in the tree and is no longer checked then remove it from the list.
Me._toolBarStyle.MultipleChecks = False means a single check tree)
Private Sub GetCheckedIDs(ByVal treeNodeList As Infragistics.Win.UltraWinTree.TreeNodesCollection, ByVal Remove As Boolean
)
Then
treeNodeList
CurrentIdList.Remove(Format.NullSafeDecimal(treeNode.Key))
Else
CurrentIdList.Add(Format.NullSafeDecimal(treeNode.Key))
If
GetCheckedIDs(treeNode.Nodes,
Next
Sub
Um.. I'm pretty sure the tree already has SelectedNodes. :)
Oh... One request for a new feature coming right up! We need a SelectedNodes and CheckedNodes collection of the Nodes property ;o)
The tree doesn't keep a list, so you either have to loop or keep track of the checked nodes yourself.
If you have a lot of nodes, I would not use a loop, since this could end up being pretty inefficient. I think keeping track of the checking and unchecking of the nodes and maintaining a List<T> or a Dictionary would be a better way to go.
Does this mean there is no easy way to retrieve a Checked Nodes list? The only way is to loop through the Nodes and look at the CheckedState property?
Put the code into a txt file
Good to know about the contains, I will try the dictionairy.