473,325 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

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
2 4841
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Plumer | last post by:
Hello everyone, I am using MS .NET Framework 1.0 Version 1.0.3705 developing a C# client application using SQL Server on the server side. I am looking to implement drag & drop in a TreeView...
3
by: Steve | last post by:
Visual Studio 2003 .NET / C# I have a treeview object on a form which acts as the main menu controller for my application. the treeview is always in sight, and the form it is on acts as the...
7
by: (Pete Cresswell) | last post by:
I've got KeyDown coding and it fires when other keys are pressed, but when Enter is pressed, nothing. I'd like to support the (standard?) Windows behavior of executing DblClick processing when...
7
by: Michael C | last post by:
Hi all, I half-resolved my previous TreeView issue. Now I was wondering if anyone knows of a way to keep a TreeNode from being highlighted when it is left-clicked? It seems like there should...
5
by: rh | last post by:
I created a user control that is made up of a TreeView and a VScrollBar. I set the TreeView.FullRowSelect = True and it works as expected (full row is visible, appears on top of everything else)...
1
by: Ravi | last post by:
Hi all. Help needed Regarding vb.net. I have the User Interface of my application, Which has a treeview on the left and a set of panels on the right(which have textboxes). When Ever i Click a...
10
by: p3t3r | last post by:
I have a treeview sourced from a SiteMap. I want to use 2 different CSS styles for the root level nodes. The topmost root node should not have a top border, all the other root nodes should have a...
1
by: Victor Rodriguez | last post by:
Is there a way that I can have a client side event like oncontextmenu="showfunction();" on each node? thanks, Victor
18
by: =?Utf-8?B?TGkgV2VuZw==?= | last post by:
Hi, Is there a way for TreeView to have multiple selections? But I am not talking about its checked boxes. I want a way similar to ListView with MultiSelect = True. So I can use or key and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.