Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 323261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:00:53+00:00 2026-05-12T09:00:53+00:00

I need to determine which tab the user is coming from, and going to,

  • 0

I need to determine which tab the user is coming from, and going to, when they switch tabs, and possibly cancel the switch. I have tried the Deselecting, Deselected, Selecting, Selected events, and all of them show the e.TabPageIndex to be the same as the sender.SelectedIndex.

Is there an event, or property, that I can use so that I can determine both sides of this, or do I have to hack something together with caching it from one event and using that value in the new event.

I am trying to avoid handling the Deselecting/Deselected events and caching the value to use in the Selecting event. I already know I can do this, so I am asking if there is a cleaner way, without doing this.

I have tried in both C# and VB, with the same results (no surprise).

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:00:53+00:00Added an answer on May 12, 2026 at 9:00 am

    It doesn’t look like any one event argument will carry the details of both the previous and current tabs, so you’ll need to handle a couple of events to keep track.

    At a minimum, you’d need to use the Deselected event to store a reference to the previously-selected tab. You can always query the TabControl for its current tab. To stretch a little further, you can also handle the Selected event to track the current tab.

    Option Strict On
    Option Explicit On
    
    Public Class Form1
    
        Private PreviousTab As TabPage
        Private CurrentTab As TabPage
    
        Private Sub TabControl1_Deselected(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlEventArgs) Handles TabControl1.Deselected
            PreviousTab = e.TabPage
            Debug.WriteLine("Deselected: " + e.TabPage.Name)
        End Sub
    
        Private Sub TabControl1_Selected(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlEventArgs) Handles TabControl1.Selected
            CurrentTab = e.TabPage
            Debug.WriteLine("Selected: " + e.TabPage.Name)
        End Sub
    
        Private Sub TabControl1_Selecting(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles TabControl1.Selecting
            If CurrentTab Is Nothing Then Return
            Debug.WriteLine(String.Format("Proposed change from {0} to {1}", CurrentTab.Name, e.TabPage.Name))
        End Sub
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two lists. I need to determine which word from the first list
I have a large list of email addresses, and I need to determine which
Often i have a problem that I need to determine which assebmly to include
I'm trying to determine which tab has been selected by the user. I melded
I have a list of websites and I need to determine which ones are
I need a way to determine which rows were deleted from the DB, given
I need to determine which version of browser the user is using, however compatibility
I have a database of geocoded entries. I need to determine which two entries
I am writing a vim plugin in which i need to determine all those
I need OCR library(preferably in Java), which will be able to determine digit visualized

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.