views:

289

answers:

4

Hello everybody.

My problem is a tree view in my Access 2002 application.

It is already populated, when I open the form. Which is strange, because the only code that adds the nodes is bound to a button.

Also, only part of the data is shown and when I switch between tabs () the data inside the tree view duplicates/doubles. When I then hit any other tab Access crashes instantly just like * zap *

Is it maybe necessary to clean a tree view all along?

Any other ideas what the problem could be - solutions also welcome ;)

Cheers, Ramon

A: 

First, find out why the TreeView is loading when you haven't told it to yet. Step through your code. You have to solve this first.

Second, does the form crash if you don't load the TreeView but do switch Tabs?

tyndall
A: 

Hi Bruno,

thank you for your suggestions.

I still did not found out why data is loaded into the TreeView, but I came up with a solution.

First I started to clean up the TreeView when the form is loaded.
That really did some good to stability. Now it is possible to click around without crashing Access.

When data is loaded to the TreeView the old behaviour shows up again. Switching between tabs adds more data and finally crashes Access.

It seems like the TreeView (Version 6.0) is rebuilding itself without cleaning up properly.
Based on this assumption, I now clear and rebuild the TreeView when switching to the containing tab.

I am still interested in the root cause, but its working now.

Thanks again, Ramon

Ramon
+1  A: 

I have come across this problem and traced it down to the treeview control does not like being on a tab page. You will have to redesign your form to keep the treeview outside the tab.

If it has to appear to be on a tab page then you could try .......

Placing the treeview behind the tab control. Setting the background of the tab control to transparant. On the "On Change" event of the tab control get it to check which tab is being selected. If it is the tab you want then set the treeview to visbale if not then hide it

Kevin Ross
A: 

I use a VCL (Delphi/BCB) wrapper as Tree View control on a tab (TTreeView on a TPageControl).

My program hangs once I call TreeView1.Items.Clear . But only in 'certain' cases! Especially if I expand an item and then try to Clear() all the items. If I never touch any node (or only scroll) it's fine.

I discovered that setting the selected node to NULL just before calling Items.Clear resolved it for me.

Interestingly, calling Clear() caused a few OnChange events to occur for some reason, which was not expected (since we were deleting all the nodes anyway!)...

E. van Putten