|
-
Jul 21st, 2009, 09:48 AM
#1
Thread Starter
Fanatic Member
VS2008: not able to cancel tabpanel validating event
Winforms, VS2008
Hi,
I have a mainform that has 2 usercontrols: UC1 and UC2.
UC1 has a treeview with treenodes. UC2 has tabControl with few tabPages. Selecting different nodes displays different details view in the TabControl's TabPages.
What I need is canceling the event when the user has selected a node in the treeview, then he selects another node (i want to be able to cancel this last event:selecting another node, all depending on a certain logic)
I mean: When the user is working on a tabpage in the tabControl, when he clicks on a different node in treeview (different from the currently selected node), before displaying the new node's details in the TabControl, I perform some logic, then depending on that logic, I set
e.cancel = true in the UC2 Validating event handler. (Rememebr UC2 includes the TabControl and the user, supposedly, has the focus on a control somewhere in TabControl)
But mysteriously, the event gets never canceled and the user still moves to the next node, displaying its details in the TabControl, although I set e.cancel = true.
Any idea, how I can solve this mystery please?
Thanks a lot.
Thanks a lot for your help.
-
Jul 21st, 2009, 10:06 AM
#2
Re: VS2008: not able to cancel tabpanel validating event
You'd handle the TreeView.BeforeSelect event of the treeview in UC1 and do you validation there. If the validation fails, you cancel the event.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Jul 21st, 2009, 10:27 AM
#3
Thread Starter
Fanatic Member
Re: VS2008: not able to cancel tabpanel validating event
 Originally Posted by stanav
You'd handle the TreeView.BeforeSelect event of the treeview in UC1 and do you validation there. If the validation fails, you cancel the event.
But the validation logic i do is in the other user control UC2 in TabControl
Thanks a lot for your help.
-
Jul 21st, 2009, 10:36 AM
#4
Re: VS2008: not able to cancel tabpanel validating event
Regardless where you perform your validation logic, if you want to stop the user from selecting a different treenode, you need to handle that treeview.beforeselect event so that you can catch when the user is trying to select a different treenode. There's no workarounds. Having said that, If you must perform the validation in UC2 where the TabControl is (which I find a little odd), you can always pass a reference of the treeview in UC1 to UC2 and handle the event there.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Jul 21st, 2009, 03:48 PM
#5
Thread Starter
Fanatic Member
Re: VS2008: not able to cancel tabpanel validating event
 Originally Posted by stanav
Regardless where you perform your validation logic, if you want to stop the user from selecting a different treenode, you need to handle that treeview.beforeselect event so that you can catch when the user is trying to select a different treenode. There's no workarounds. Having said that, If you must perform the validation in UC2 where the TabControl is (which I find a little odd), you can always pass a reference of the treeview in UC1 to UC2 and handle the event there.
Great thank you very much, I did that and it's working.
Tell me pls, will there be a way to cancel the event of the user clicking somewhere outside the UC2 by using a logic in UC2. I mean whether he clicks on the treeview, or anywhere else on the form, or do I have to do that on each event seperately?
Thanks
Thanks a lot for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|