Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
380
List of Checked Nodes
posted

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

)

 

 

If treeNodeList IsNot Nothing

Then

 

 

For Each treeNode As UltraTreeNode In

treeNodeList

 

 

If Remove

Then

 

 

If CurrentIdList.Contains(Format.NullSafeDecimal(treeNode.Key)) Then

CurrentIdList.Remove(Format.NullSafeDecimal(treeNode.Key))

 

 

Else

 

 

If treeNode.CheckedState = CheckedStatus.Checked

Then

 

 

If Not CurrentIdList.Contains(Format.NullSafeDecimal(treeNode.Key)) Then

CurrentIdList.Add(Format.NullSafeDecimal(treeNode.Key))

 

 

Else

 

 

If CurrentIdList.Contains(Format.NullSafeDecimal(treeNode.Key)) Then

CurrentIdList.Remove(Format.NullSafeDecimal(treeNode.Key))

 

 

End

If

 

 

End

If

 

 

If treeNode.Nodes IsNot Nothing AndAlso treeNode.Nodes.Count > 0

Then

 

 

If Not treeNode.CheckedState = CheckedStatus.Checked

Then

GetCheckedIDs(treeNode.Nodes,

 

False

)

 

 

Else

 

 

If Me._toolBarStyle.MultipleChecks

Then

GetCheckedIDs(treeNode.Nodes,

 

True

)

 

 

Else

GetCheckedIDs(treeNode.Nodes,

 

False

)

 

 

End

If

 

 

End

If

 

 

End

If

 

 

Next

 

 

End

If

 

 

End

Sub