Bug with TreeView control

J

Jim

The below problem occurs randomly too, but I've managed to isolate a
sequence of events when it always happens:

I have two forms (say Form1 and Form2). Form 1 contains a TreeView control.
A button from Form1 opens Form2 and a button in Form2 sends the user back to
Form1.

When the user goes back to Form1 from Form2, the TreeView control rebuilds
the nodes incredibly slowly. You can see the progress, as the scroll bar
slowly starts sliding down. It normally takes around 30 seconds to rebuild
the tree. When the tree is finished, every node is fully expanded. Also,
when I go into edit mode, the TreeView control displays all the data, rather
than the more usual "Sample Node" mini-tree.

Can anyone help? The TreeView control is essential to my application, and I
can't expect users to wait 30 seconds each time they switch between forms
while the TreeView does its very weird stuff.

Thanks
Jim
 
G

Guest

Are you closing Form1 when you open Form2 or just setting the Visible Property to False

Thanks.
 
A

Alex Dybenko

hmm, not clear why TV starts to rebuild. do you have some code for this run
when you switch to form? normally it just stays as it is when form
activated/deactiuvated
 
J

Jim

That's why it's so bizarre. I only build the tree once, yet when I switch
between forms, it rebuilds itself extremely slowly. if i get a chance, i'll
try and replicate it and give you a url to a db so you can see for yourself.

By the way, the problem fixes itself if i remove and readd the tree .... but
only temporarily.

Thanks
Jim
 
B

Bradley

Try turning off the option "Track name AutoCorrect info"?

This causes a slowdown of complex forms once the design is changed.
 
J

Jim

Bradley

Thanks for your reply. It sounded like a great idea, and something I
would never have thought of. Unfortunately though, it didn't work.

I've now isolated the offending line, which is:

xTree.Object.Nodes.Clear

in the Form_Open sub (xTree being the instance of the Tree Control)

Can anyone tell me if I'm doing something blatently wrong? As I
mentioned in a previous post, I don't get this problem on other PCs,
yet the offending line, if removed, removes the problem on my PC.

Thanks
Jim
 
A

Alex Dybenko

Hi,
1. do not use form Open event - use only Load event to work with activex
controls
2. during clear operation TV redraws a lot, so try to switch it off:

SendMessage oTV.hWnd, WM_SETREDRAW, 0, ByVal 0&
oTV.Nodes.Clear
SendMessage oTV.hWnd, WM_SETREDRAW, 1, ByVal 0&

in declration section:
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As _
Any) As Long

Public Const WM_SETREDRAW = &HB

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top