469,575 Members | 1,377 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,575 developers. It's quick & easy.

[noobie] TreeView AfterSelect event

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
Nov 16 '05 #1
3 5444
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

"Christoph Boget" <jc*****@yahoo.com> wrote in message
news:Ow**************@TK2MSFTNGP09.phx.gbl...
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

Nov 16 '05 #2
> 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
Nov 16 '05 #3
> 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

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Sreepathi Rao Konchada | last post: by
reply views Thread by Mehdi Mousavi | last post: by
6 posts views Thread by Tim | last post: by
1 post views Thread by mongphong28 | last post: by
9 posts views Thread by auntiejack56 | last post: by
2 posts views Thread by =?Utf-8?B?anAybXNmdA==?= | last post: by
2 posts views Thread by govolsbaby | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.