TreeView redraw lag..
-
my treeview is very very laggy when calling
TreeView.Nodes.Clear
.. ive found that if i callTreeView.Invisible = TRUE
before clearing the tree, then make it visible again afterwards that it is much much faster.. in C++ i use a comandSetRedraw(FALSE)
before clearing the list, thenSetRedraw(TRUE)
afterwards.. is there anything like this for VB, or is making the list invisible the only hack? populating the list is just as slow as well unless i make it invisible first.. anyway to turn off the redraw without making it invisible? thanks! still a newb.. cut me some slack :P -dz -
my treeview is very very laggy when calling
TreeView.Nodes.Clear
.. ive found that if i callTreeView.Invisible = TRUE
before clearing the tree, then make it visible again afterwards that it is much much faster.. in C++ i use a comandSetRedraw(FALSE)
before clearing the list, thenSetRedraw(TRUE)
afterwards.. is there anything like this for VB, or is making the list invisible the only hack? populating the list is just as slow as well unless i make it invisible first.. anyway to turn off the redraw without making it invisible? thanks! still a newb.. cut me some slack :P -dz -
my treeview is very very laggy when calling
TreeView.Nodes.Clear
.. ive found that if i callTreeView.Invisible = TRUE
before clearing the tree, then make it visible again afterwards that it is much much faster.. in C++ i use a comandSetRedraw(FALSE)
before clearing the list, thenSetRedraw(TRUE)
afterwards.. is there anything like this for VB, or is making the list invisible the only hack? populating the list is just as slow as well unless i make it invisible first.. anyway to turn off the redraw without making it invisible? thanks! still a newb.. cut me some slack :P -dzDoh! Sorry, using .NET here... Anyway, use the API Function "LockWindowUpdate". Public Declare Function LockWindowUpdate Lib "user32" (ByVal hWndLock As Long) As Long Then, use this function when Populating or Clearing the TreeView. Call LockWindowUpdate(Tree.hWnd) 'Populate or Clear Nodes Call LockWindowUpdate(0) Always remember to "UnLock" after you are done, otherwise it never repaints. Also, if you are updating more controls (i.e. ComboBoxes) that are on the same Form, just Lock the Whole Form that way painting will not occur on any controls. I use this in my App all the time and it has sped up the process of loading Forms by up to 70%!
-
Doh! Sorry, using .NET here... Anyway, use the API Function "LockWindowUpdate". Public Declare Function LockWindowUpdate Lib "user32" (ByVal hWndLock As Long) As Long Then, use this function when Populating or Clearing the TreeView. Call LockWindowUpdate(Tree.hWnd) 'Populate or Clear Nodes Call LockWindowUpdate(0) Always remember to "UnLock" after you are done, otherwise it never repaints. Also, if you are updating more controls (i.e. ComboBoxes) that are on the same Form, just Lock the Whole Form that way painting will not occur on any controls. I use this in my App all the time and it has sped up the process of loading Forms by up to 70%!
-
my treeview is very very laggy when calling
TreeView.Nodes.Clear
.. ive found that if i callTreeView.Invisible = TRUE
before clearing the tree, then make it visible again afterwards that it is much much faster.. in C++ i use a comandSetRedraw(FALSE)
before clearing the list, thenSetRedraw(TRUE)
afterwards.. is there anything like this for VB, or is making the list invisible the only hack? populating the list is just as slow as well unless i make it invisible first.. anyway to turn off the redraw without making it invisible? thanks! still a newb.. cut me some slack :P -dzActually, I figured I would Post this here. This function will Lock as many Windows as you want from Redrawing...unlike the "LockWindowUpdate" Function.
'API Declarations (.NET)
Private Declare Ansi Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
'Routine to Lock a Window from Repainting
Public Sub LockWindowUpdate(ByVal Handle As IntPtr, ByVal Lock As Boolean)
Const WM_SETREDRAW As Integer = &HB'Enable / Disable Drawing Call SendMessage(Handle, WM\_SETREDRAW, Math.Abs(CInt(Lock)), 0)
End Sub
'API Declarations (VB6)
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'Routine to Lock a Window from Repainting
Public Sub LockWindowUpdate(ByVal Handle As Long, ByVal Lock As Boolean)
Const WM_SETREDRAW As Long = &HB'Enable / Disable Drawing Call SendMessage(Handle, WM\_SETREDRAW, Abs(CInt(Lock)), 0)
End Sub