Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / Canceling Tab Change – UltraWinTabControl

Canceling Tab Change – UltraWinTabControl

New Discussion
Stephen Crook
Stephen Crook asked on Oct 16, 2020 8:12 PM

Maybe this is not the correct control to do what I'm trying to do, but ..

I have an UltraWinTabControl with several tabs on the top of my form, the bottom of my form is an UltraWinGrid.

I am using the .ActiveTabChanged event to set the datasource of the Grid based on the ActiveTabChangedEventArgs Tab.Key property.

What I am looking for is a means to see what tab I am leaving BEFORE I leave it because I would like to:

1) check that the grid data has been saved, and cancel the tab change if not.

2) Save any user applied filters to the grid for that tab to re-apply when the tab becomes active again

I cannot seem to find any means to do this BEFORE the actual change happens.

The ActiveTabChangedEventArgs  has a .PreviousTab property but by the time this event fires, the change is completed and it has no .Cancel property

 

The ActiveTabChangingEventArgs has a .Cancel property but the .Tab property still points to the tab it's changing into not the one it's leaving and it has no .PreviousTab property.

I suppose I could do everything in the AfterTabChanged event and then switch back to the .PreviousTab if it fails but the fact that .ActiveTabChanging has a .Cancel property makes me think there should be a cleaner / simpler way to do this.

Am I missing something or is there a better way to handle this?

Thanks

Steve

Sign In to post a reply

Replies

  • 0
    Andrew Goldenbaum
    Andrew Goldenbaum answered on Oct 16, 2020 7:07 PM

    Hello Steve,

    I have been investigating into your requirement, and I would recommend that you continue with the ActiveTabChanging event in this case.

    The reason that the event arguments of the ActiveTabChanging event does not have a PreviousTab property is because when this event fires, the ActiveTab property of the UltraTabControl has not yet changed. As such, you can get this “previous tab” from the ActiveTab property of the UltraTabControl.

    Please let me know if you have any other questions or concerns on this matter.

    • 0
      Stephen Crook
      Stephen Crook answered on Oct 16, 2020 8:12 PM

      Thank You Andrew

      Insert Major Face Palm here.

      Assuming we have 3 Tabs; TabA, TabB, and TabC

      and we start on TabA

      and we click TabB

      Private Sub utc_Main_ActiveTabChanging(sender As Object, e As ActiveTabChangingEventArgs) Handles utc_Main.ActiveTabChanging
              
          utc_Main.ActiveTab
      
          e.Tab
      
      End Sub

      I totally missed the fact that .ActiveTab would still be "TabA" because the change event had not completed yet

      and was totally hung up on the fact that e.Tab was "TabB" and in my mind I kept expecting it to be "TabA" as well.

      Thanks for getting me back on track!!

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Stephen Crook
Favorites
0
Replies
2
Created On
Oct 16, 2020
Last Post
5 years, 11 months ago

Suggested Discussions

Created by

Created on

Oct 16, 2020 8:12 PM

Last activity on

Oct 16, 2020 8:12 PM