• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

Quickly moving through a treeview causing crashes.

Been a while since I asked a question, but I wanted to get some thoughts on the best way to handle this scenario.

I have a standard treeview which gets populated at runtime, and then depending on what node you select, it goes to the database to get quite a bit of information each time to populate some frames.

The issue I am having, which I doubt is uncommon, is that if you move up and down the treeview fast using the mouse, the application crashes because it hasnt finished getting the previous information requested at the same time I am asking it to get the next nodes information etc.

What is the best way to handle this? Best way to almost halt the application while it retrieves the data it was asked for, then allow the user to move node again etc etc

Cheers fellow experts
3 Solutions
what about to disable the tree temporary and enable after the db.load is ready?
mikelittlewoodAuthor Commented:
Yeah I was wondering if it might be as simple as that, but was also wondering if there was an elegant way to do it.

Currently using the OnChange I set a flag called bMoving to True and then at the end of the OnChange event Im setting it to false.
Then on the OnChanging event Im doing AllowChange := not bMoving so that if it is already trying to do something it wont let the user change node.
Hopefully this is the easiest way to handle the scenario.

Ill hold on and see if anyone else comes up with another suggestion.
Another way that works with DB Searches as well is to kick of a timer on the ONChange event. The timer only needs to be set to 500msecs

So you get lv.OnChange
//this resets the timer value to 500

then in the OnTimer event add the codefor the rest of the work.

This has the effect that if someone just holds down the up or down key then the timer keeps getting reset until the user stops and then the screen updates with the rest.

This works well, I know I've used it thousands of times. but, and ofcouse theres always a but you still need to watch out for the timer firing twice.

What you can do is to have a global Cancel flag and at regular intervals in your main update code check that flag and bail out if neccessary

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

mikelittlewoodAuthor Commented:
Thanks for the suggestion pcsentinel.
or you can have a look at virtualtreeview http://soft-gems.net/VirtualTreeview ... been using that for some time, and haven't had such prob...
mikelittlewoodAuthor Commented:
Cheers for the advice all .. Ill give everyone a share of the points for the info
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now