Print Page | Close Window

Treeview slow when refreshing its contents

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=15862
Printed Date: 26 November 2024 at 9:15pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Treeview slow when refreshing its contents
Posted By: od@eureka
Subject: Treeview slow when refreshing its contents
Date 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



Replies:
Posted By: Oleg
Date 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


Posted By: od@eureka
Date 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


Posted By: Baldur
Date 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.


Posted By: Oleg
Date 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


Posted By: Baldur
Date Posted: 06 January 2010 at 12:40pm
I'm still waiting for 13.2.2 now because i have actually no issues ;)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net