Hi Guys,
I am using VB.net created a User Control and put it into a palette.
I have a functio populate treeview inside the user control. My treeview need to be populated when the palette display, so I put load treeview function into my User control load event.
It cause the palette long time to display.
Ideally I would like the palette to be shown with mouse icon as wait glass, once the treeview populated mouse icon back to arrow shape
Any ideas?
Thanks very much
Regards,
Yaqi
You should hide the treeview while it is being updated. Otherwise it will update the screen with each item that is updated.
I'd use the built in progress meter as your curser may not actually update if your program is busy.
Imports Autodesk.AutoCAD.Runtime Public Class clsProgress Dim pm As ProgressMeter ' AutoCad progress bar Sub ProgressBar(ByVal BarText As String, ByVal numItems As Integer, ByVal counter As Integer) ' meter won't update untill 6 or 7 iterations ??? numItems *= 10 counter *= 10 If pm Is Nothing Then pm = New ProgressMeter() pm.Start(BarText) pm.SetLimit(numItems) Else System.Threading.Thread.Sleep(1) Autodesk.AutoCAD.ApplicationServices.Application.UpdateScreen() 'Increment Progress Meter... For i = 0 To 9 System.Threading.Thread.Sleep(1) pm.MeterProgress() Next System.Windows.Forms.Application.DoEvents() End If If counter = numItems Then pm.Stop() pm = Nothing End If End Sub End Class
Don't load the treeview in the user control. Load it before you show the palette.
There is more than 1 way to do that. The nodes of a treeview are a collection. You can create a collection somewhere in your code and then assign that collection to the treeview before you show the palette. That way it is built already.
Hi,
if the time is used by the TreeView (adding the nodes) then you can use the properties .SuspendLayout and .ResumeLayout. That disables the paints from getting active and so that runs much faster than without (there you see node by node getting added).
HTH, - alfred -
If there are too many nodes to load in the treeview and the nodes may be many levels deep, the common approach is not to load all the possible nodes recusively. You only load the top level nodes (say, the root node), and their immediate child notes and then stop going deeper. Make sure the top level node collapsed. When user double-click the top level node to expand it, load the node's child nodes' child nodes in the node.Expand even handler. The treeview then only is fully loaded when all the nodes in second deepest level are clicked to be expanded.
This is how Widows Explorer works to show disk file structure. You can imagine, if Windows Explorer has to load all folders in the treeview node in one shot when there is a huge disk with thousands of thousands of file folders, how much time it would take! and how user feels.
Norman Yuan