Treeview Sort and Group Nodes
Hello All,
I have Extended treeview, in order to have Multiselect.
I also have Extended three different types of nodes Group, Project and ProjectDirectory from Treenode.
The Hirarchy is like Bellow
+Group1
+ ProjectNodeA
-ProjectDirectory Node 1
Group2
+ ProjectNodeB
-ProjectDirectory Node 1
I want to Sort the Group and ProjectNodes and then Display the GroupNodes first and then Project Nodes
Current solution i have is
Code:
Private Sub SortNodes()
Dim pnodes As New List(Of KurmaahTreeNode)
Dim gnodes As New List(Of KurmaahTreeNode)
For Each nnode As KurmaahTreeNode In Me.TreeView.Nodes
If nnode.NodeType = TypeOfNode.GroupNode Then
gnodes.Add(nnode.Clone())
ElseIf nnode.NodeType = TypeOfNode.ProjectNode Then
pnodes.Add(nnode.Clone())
End If
Next
Dim tempparray() As KurmaahTreeNode = Nothing
Dim tempgarray() As KurmaahTreeNode = Nothing
Array.Resize(tempparray, pnodes.Count)
Array.Resize(tempgarray, gnodes.Count)
tempparray = pnodes.ToArray()
tempgarray = gnodes.ToArray()
Try
Array.Sort(tempparray, New TreeNodeComparer)
Array.Sort(tempgarray, New TreeNodeComparer)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Me.TreeView.Nodes.Clear()
Me.TreeView.Nodes.AddRange(tempgarray)
Me.TreeView.Nodes.AddRange(tempparray)
End Sub
But the problem is that when i try to Call the function from AfterLabelEdit, weird behavior is observed
Is there a better way to do this ??
Can anyone guide me on this thanks
Re: Treeview Sort and Group Nodes
what exactly is happening?
Re: Treeview Sort and Group Nodes
The Sort method runs infinitly and then ERROR pops up
Quote:
Context 0x4aa77a0' is disconnected. Releasing the interfaces from the current context (context 0x4aa7630).This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the applicationis completely done with the RuntimeCallableWrappers that represent COM components that liveinside them.