.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Load Palette take long time, how to solve it?

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
325 Views, 5 Replies

Load Palette take long time, how to solve it?

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

5 REPLIES 5
Message 2 of 6
arcticad
in reply to: Anonymous

You should hide the treeview while it is being updated. Otherwise it will update the screen with each item that is updated.

---------------------------



(defun botsbuildbots() (botsbuildbots))
Message 3 of 6
arcticad
in reply to: arcticad

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

 

---------------------------



(defun botsbuildbots() (botsbuildbots))
Message 4 of 6
fieldguy
in reply to: Anonymous

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.

Message 5 of 6
Alfred.NESWADBA
in reply to: Anonymous

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 -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 6 of 6
norman.yuan
in reply to: Anonymous

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

Drive CAD With Code

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost