We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

TabControlExt - tab changing

Thread ID:

Created:

Updated:

Platform:

Replies:

6885 Sep 3,2003 05:55 AM Sep 4,2003 10:25 AM Windows Forms 6
loading
Tags: Tools
Paul Laudeman
Asked On September 3, 2003 05:55 AM

Does anyone know how I can consume and, if need be, cancel the change event of the current tab before it changes? Thanks!

Arun Srinivasan [Syncfusion]
Replied On September 3, 2003 07:37 AM

Hi Paul You can listen to the Validating Event of the current tab and cancel or invalidate it based on what you want to do, to do what you are looking for. Arun > Does anyone know how I can consume and, if need be, cancel the change event of the current tab before it changes? > > Thanks!

Paul Laudeman
Replied On September 3, 2003 08:33 AM

Unfortunlatey, that won't work for my purposes. On my TabPageExt I have a user control that contains a grid and another user control that we use to navigate between the tabs. The only time I can get the validating or validated events for the tab page to fire is when I click on another tab. If I click on a control within the tab that causes the current tab to be changed, the validating events won't fire. > Hi Paul > You can listen to the Validating Event of the current tab and cancel or invalidate it based on what you want to do, to do what you are looking for. > > Arun > > > > > Does anyone know how I can consume and, if need be, cancel the change event of the current tab before it changes? > > > > Thanks! >

Ramesh Praveen [Syncfusion]
Replied On September 3, 2003 11:47 AM

Paul, Yes, the selected tab can still be changed programatically. But, that chould easily be worked around by simply calling the Validate method on the container control, before changing the selected index. Something like this: bool validated = tabControl.GetContainerControl().Validate(); if(validated) // go ahead and change the selected tab else // do not switch the tab. Do let us know if this will work for you. Regards, -Praveen

Paul Laudeman
Replied On September 4, 2003 06:14 AM

Hi Praveen, Thanks for your reply. When I try to access the container control for either the tabpage or the tabstrip control itself, I get a reference to the form that contains the tabstrip control, which isn't what I really need. My solution to my problem was to modify the source for TabPageExt control and add an event called SelectedIndexChanging. This way, I could add an event handler to that event and, if I chose to, I could cancel the event and prevent the tab from ever changing. The problem was that I needed to handle the tab index change that could occur from either clicking another tab or by programmatically selecting another tab through code. -Paul > Paul, > > Yes, the selected tab can still be changed programatically. But, that chould easily be worked around by simply calling the Validate method on the container control, before changing the selected index. Something like this: > > bool validated = tabControl.GetContainerControl().Validate(); > if(validated) > // go ahead and change the selected tab > else > // do not switch the tab. > > Do let us know if this will work for you. > > Regards, > -Praveen >

Ramesh Praveen [Syncfusion]
Replied On September 4, 2003 07:18 AM

Paul, I just wanted to clarify a lit bit more. Ok, the logic I suggested to "validate" the current tab page didn't work for you. But, whatever logic you use in the new SelectedIndexChanging event to "validate", can you not use that same logic BEFORE setting a new SelectedIndex programatically? Regards, Praveen

Paul Laudeman
Replied On September 4, 2003 10:25 AM

Yes, that would work if I knew ahead of time what validation routines to run before changing the selcted index programmatically. However, the control we developed to do the programmatic changing is designed to work with any tab page, without regard to specific content. Ideally, when we programmatically change the selected index it would fire the validating events for the TabPage (which would recursively call the validating events of all controls on that page), and then I could just add an event handler in my user control to handle the validating event. Since that wasn't possible, I thought adding a SelectedIndexChanging event would be another way to meet our needs. One other option, along the lines you of what you suggested, might be to loop through all the controls on a TabPage and see if they implemented a method to do custom validation and call that before programmatically changing the selected index. -Paul > Paul, > > I just wanted to clarify a lit bit more. > > Ok, the logic I suggested to "validate" the current tab page didn't work for you. But, whatever logic you use in the new SelectedIndexChanging event to "validate", can you not use that same logic BEFORE setting a new SelectedIndex programatically? > > Regards, > Praveen

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;