|  | 
| Treeview slow when refreshing its contents | 
| Post Reply   | 
| Author | |
| od@eureka   Newbie   Joined: 15 December 2009 Location: France Status: Offline Points: 4 |  Post Options  Thanks(0)  Quote  Reply  Topic: Treeview slow when refreshing its contents Posted: 15 December 2009 at 10:58am | 
| 
   I have to refresh the contents of a Treeview :
 - by default, it show all values (approximativly 1500 nodes) - when using filters, users can reduce the number of nodes to a subset of 150 or less I do a small test:         myTreeView.Nodes.Clear Dim i As Integer For i = 1 To 100 myTreeView.Nodes.Add Parent, xtpTreeViewChild, i, "line " & CStr(i), 3 Next --> it is very slowly the 2nd or more times...(> 4 sec !!!)  How to do to go faster ? (the first time, for 1500 nodes, it takes only 1 sec ) | |
| 
     Regards
 Didier | |
|  | |
| Oleg   Senior Member   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |  Post Options  Thanks(0)  Quote  Reply  Posted: 16 December 2009 at 5:46am | 
| 
   Hi,
 You can try WM_SETREDRAW API message: Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Const WM_SETREDRAW = &HB Private Sub Command1_Click() SendMessage myTreeView.hwnd, WM_SETREDRAW, 0, 0 myTreeView.Nodes.Clear Dim i As Integer For i = 1 To 1000 myTreeView.Nodes.Add Parent, xtpTreeViewChild, i, "line " & CStr(i), 3 Next SendMessage myTreeView.hwnd, WM_SETREDRAW, 1, 0 End Sub | |
| 
     Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS | |
|  | |
| od@eureka   Newbie   Joined: 15 December 2009 Location: France Status: Offline Points: 4 |  Post Options  Thanks(0)  Quote  Reply  Posted: 16 December 2009 at 8:11am | 
|  Thank you for the solution that solves well the response time ... But unfortunately, after several calls of myTreeView.Nodes.Clear(), I have an error code 80010108 ...  --> Is there another way to empty the entire TreeView? | |
| 
     Regards
 Didier | |
|  | |
| Baldur   Senior Member   Joined: 22 November 2006 Location: Germany Status: Offline Points: 244 |  Post Options  Thanks(0)  Quote  Reply  Posted: 04 January 2010 at 4:39am | 
| 
   I got the same error including crash of the application if i often use the clear-method.
 It's faster and also save to remove the nodes, but from last node to first node ! Also use in this case the WM_SETREDRAW. | |
|  | |
| Oleg   Senior Member   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |  Post Options  Thanks(0)  Quote  Reply  Posted: 05 January 2010 at 8:22am | 
| 
   do you have last version, it was minor problem with Clear method but it have to be fixed in 13.2.x
    | |
| 
     Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS | |
|  | |
| Baldur   Senior Member   Joined: 22 November 2006 Location: Germany Status: Offline Points: 244 |  Post Options  Thanks(0)  Quote  Reply  Posted: 06 January 2010 at 12:40pm | 
| 
   I'm still waiting for 13.2.2 now because i have actually no issues ;)
    | |
|  | |
| Post Reply   | |
| Tweet | 
| Forum Jump | Forum Permissions  You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |