Hi all,
first I am a newbie so take note please. I have two treeviews which are filled with .xls files. I am comparing them for any changes but if there are many nodes the application is not responding. Here is my code for better imagination:
The problem is in ColorSameChilds() and I want to ask if there is some faster way how to read data. Can you tell me for example if reading dataset or array is faster then reading treeview. Or can you recommend me any article with sort of these information (useful tips to make fast code). There are about 1k parent nodes in treeview
Thank you
first I am a newbie so take note please. I have two treeviews which are filled with .xls files. I am comparing them for any changes but if there are many nodes the application is not responding. Here is my code for better imagination:
'This colors parent nodes in 1st treeview which are in 2nd treeview green and those which are not red
Public Sub ColorParent()
For Each Me.parentnode In TreeView1.Nodes
FindParent = TreeView2.Nodes.Find(TreeView1.Nodes(parentnode.Index).Name, False)
On Error Resume Next
If FindParent.Count = 0 Then
TreeView1.Nodes(parentnode.Index).BackColor = Color.Red
Else
TreeView1.Nodes(FindParent(0).Name).BackColor = Color.Green
End If
Next parentnode
End Sub
'This colors all childs in 1st treeview with childs which are in 2nd treeview at same parents
Public Sub ColorSameChilds()
For Each Me.parentnode In TreeView1.Nodes
For Each Me.parentnode2 In TreeView2.Nodes
For Each Me.childnodeTV1 In TreeView1.Nodes(parentnode.Index).Nodes
For Each Me.childnodeTV2 In TreeView2.Nodes(parentnode2.Index).Nodes
FindChild = TreeView2.Nodes(parentnode2.Index).Nodes.Find(TreeView1.Nodes(parentnode.Index).Nodes(childnodeTV1.Index).Name, False)
On Error Resume Next
If FindChild.Count > 0 Then
If TreeView1.Nodes(parentnode.Index).BackColor = Color.Green Then
TreeView1.Nodes(parentnode.Index).Nodes(childnodeTV1.Index).BackColor = Color.Green
End If
End If
Next childnodeTV2
Next childnodeTV1
Next parentnode2
Next parentnode
End Sub
'This just color parents in 1st treeview to orange if there is any uncolored child
Public Sub ColorDifferentChilds()
For Each Me.parentnode In TreeView1.Nodes
For Each Me.childnodeTV1 In TreeView1.Nodes(parentnode.Index).Nodes
If TreeView1.Nodes(parentnode.Index).BackColor <> Color.Red Then
If TreeView1.Nodes(parentnode.Index).Nodes(childnodeTV1.Index).BackColor = Nothing Then
TreeView1.Nodes(parentnode.Index).Nodes(childnodeTV1.Index).BackColor = Color.Orange
TreeView1.Nodes(parentnode.Index).BackColor = Color.Orange
End If
End If
Next childnodeTV1
Next parentnode
End Sub
The problem is in ColorSameChilds() and I want to ask if there is some faster way how to read data. Can you tell me for example if reading dataset or array is faster then reading treeview. Or can you recommend me any article with sort of these information (useful tips to make fast code). There are about 1k parent nodes in treeview
Thank you