[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do you get the PreviousTab in a tab control in vb.net

Posted on 2007-10-11
4
Medium Priority
?
744 Views
Last Modified: 2013-11-26
In VB6 we had

Private Sub SSTab1_Click(PreviousTab As Integer)

end sub

Can we get the previous tab in VB.Net, or is this something we have to set up manually?
0
Comment
Question by:grwallace
  • 2
4 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 20056889
I think we have to do it manually! At least I do it and I don't know another way.
0
 
LVL 2

Expert Comment

by:dhwanilshah
ID: 20057251
There are several events available on the Tab control, the most promising one is -

------------------------------------------------
Public Event Selecting(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs)
     Member of: System.Windows.Forms.TabControl
Summary:
Occurs before a tab is selected, enabling a handler to cancel the tab change.
------------------------------------------------

If the TabControlCancelEventArgs, contains the tab / index which is going to  be selected, then you can get the currently selected tab / index from the Tab control and the going-to-be-selected from the TabControlCancelEventArgs.
0
 

Author Comment

by:grwallace
ID: 20058075
I'm not sure how to extract the value from the TabControlEventsArg, but this looks like what I want
0
 
LVL 2

Accepted Solution

by:
dhwanilshah earned 1500 total points
ID: 20059143
I tried out on a project ------ actually the event you are looking for ------ if you want to cancel navigation to some other tab, then you can use the Deselecting event on the TabControl --- here is a snippet

Private Sub TabControl1_Deselecting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles TabControl1.Deselecting
   MessageBox.Show(TabControl1.SelectedIndex.ToString())
   MessageBox.Show(e.TabPageIndex.ToString())

End Sub

If I am on TabPage 1, and click on TabPage 2, then it shows 0 and 0 respectively ----- which means, that I cannot find out which the next-tab-is-going-to-be........

This event, does allow you to cancel the navigation ------ you can use e.Cancel = True
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Integration Management Part 2
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month17 days, 23 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question