[noobie] TreeView AfterSelect event

C

Christoph Boget

I have a TreeView object that I'm filling in with the directory
structure. However, for the sake of this learning exercise, I
am making it flat. So that when a user clicks on the directory
name, I refresh the TreeView with the contents of the new
directory. All that is more or less working.
What I've noticed is that if I select node X, when I Clear()
the nodes and go to refresh with the contents of the new
directory, the AfterSelect event (or, at least, my AfterSelect
event method) is triggered for node X-1 through node 0 in
turn. Why is that? How can I make it so that the event is
triggered only once and only when a node is clicked?

thnx,
Chris
 
A

AlexS

Hi, Christoph

This is by design. So, you have to check if node is selected (or clicked as
you say) in your AfterSelect handler and act accordingly.
You might want to experiment also with BeginUpdate/EndUpdate calls around
your tree filling code.

HTH
Alex
 
C

Christoph Boget

This is by design. So, you have to check if node is selected (or clicked
as
you say) in your AfterSelect handler and act accordingly.
You might want to experiment also with BeginUpdate/EndUpdate calls around
your tree filling code.

I'm checking to see if the node is selected/clicked but it seems as if every
time the AfterSelect handler is executed, every node that is passed to it is
set as selected whether or not it's the one I actually clicked on.
You can see my code here:

http://www.geocities.com/jcboget/MView.html

If you copy and paste it to run yourself, just remove the "<pre>" tags
(obviously). Also, I have it so that my tabs are set to "2 spaces".
Finally,
as you are looking at the code, please keep in mind that I am a relative
newbie at windows programming. I may not be doing things as efficiently
as possible. I'm writing this app as a learning process. And as for the
TreeView control, I'm intentionally using it to display the directory
structures
flat.

In any case, back to my problem: why is it that the AfterSelect handler is
working with every node and why does it think that every node has been
selected?

thnx,
Christoph
 
C

Christoph Boget

This is by design. So, you have to check if node is selected (or clicked
as
you say) in your AfterSelect handler and act accordingly.
You might want to experiment also with BeginUpdate/EndUpdate calls around
your tree filling code.

I'm checking to see if the node is selected/clicked but it seems as if every
time the AfterSelect handler is executed, every node that is passed to it is
set as selected whether or not it's the one I actually clicked on.
You can see my code here:

http://www.geocities.com/jcboget/MView.html

If you copy and paste it to run yourself, just remove the "<pre>" tags
(obviously). Also, I have it so that my tabs are set to "2 spaces".
Finally,
as you are looking at the code, please keep in mind that I am a relative
newbie at windows programming. I may not be doing things as efficiently
as possible. I'm writing this app as a learning process. And as for the
TreeView control, I'm intentionally using it to display the directory
structures
flat.

In any case, back to my problem: why is it that the AfterSelect handler is
working with every node and why does it think that every node has been
selected?

thnx,
Christoph
 

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