Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1850
Go to previous selected tab?
posted

Is there a way to select the previous selected tab when closing the current selectedTab?

 

-Ken 

Parents
  • 1850
    Verified Answer
    posted

    Answered my own question...I rolled my own code.  BTW: When a tab is closed it isn't really removed from the collection and that throws selecting off at times. If you select a tab that has been closed you just see a blank tab panel.

    My code looks like this:

          private void OnSelectedTabChanging(object sender, SelectedTabChangingEventArgs e)
          {
             UltraTabControl aTabControl = sender as UltraTabControl;
    
             if (aTabControl != null && aTabControl.SelectedTab != null)
                previousTabIndex = aTabControl.SelectedTab.Index;
          }
          
          private void OnTabClosing(object sender, TabClosingEventArgs e)
          {
             this.AccountTabControl.SelectedTab = this.AccountTabControl.Tabs[previousTabIndex];
          }
          
          void OnTabClosed(object sender, TabClosedEventArgs e)
          {
             if(e.CloseReason == TabCloseReason.CloseButton)
                this.AccountTabControl.Tabs.Remove(e.Tab);
          }
    
Reply Children
No Data