467,161 Members | 991 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

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

Treeview events

I have a treeview linked to a series of panels, making the correct
panel visible depending on which node is selected.

I now want to check that the user is allowed to leave the current node
they're on before letting them do so (popping up a "You have unsaved
data - save?" box).

However, there doesn't seem to be a "BeforeLeaving" event that fires
before focus changes from one node to another.

Am I missing something, or do I have to just code my way around it?

Cheers,

Andy D

Nov 23 '05 #1
  • viewed: 4641
Share:
2 Replies
I assume you are speaking of the Windows Forms Treeview species.
Treeview exposes a number of events, including MouseUp and MouseDown.
If you have stored the node a user is on, you can perform your test in the
MouseDown event, checking to see if they have "Mouse Downed" onto a new node,
and do your validation check and "popup" before allowing the rest of your
event handler code to execute.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Andrew Ducker" wrote:
I have a treeview linked to a series of panels, making the correct
panel visible depending on which node is selected.

I now want to check that the user is allowed to leave the current node
they're on before letting them do so (popping up a "You have unsaved
data - save?" box).

However, there doesn't seem to be a "BeforeLeaving" event that fires
before focus changes from one node to another.

Am I missing something, or do I have to just code my way around it?

Cheers,

Andy D

Nov 23 '05 #2
Andrew,

Thre is no BeforeLeaving event, but there is BeforeSelect event that covers
exactly your case.

Handle this event and check SelectedNode (this is the node that currently is
selected). Do the validation and if the data haven't been saved yet, set the
event argument's property Cancel to *true* this will cancel changing the
selection and will keep the previously selected node.
HTH
Stoitcho Goutsev (100) [C# MVP]

"Andrew Ducker" <an****@ducker.org.uk> wrote in message
news:11********************@g14g2000cwa.googlegrou ps.com...
I have a treeview linked to a series of panels, making the correct
panel visible depending on which node is selected.

I now want to check that the user is allowed to leave the current node
they're on before letting them do so (popping up a "You have unsaved
data - save?" box).

However, there doesn't seem to be a "BeforeLeaving" event that fires
before focus changes from one node to another.

Am I missing something, or do I have to just code my way around it?

Cheers,

Andy D

Nov 24 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Plumer | last post: by
3 posts views Thread by Steve | last post: by
7 posts views Thread by (Pete Cresswell) | last post: by
7 posts views Thread by Michael C | last post: by
1 post views Thread by Victor Rodriguez | last post: by
18 posts views Thread by =?Utf-8?B?TGkgV2VuZw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.