Solved

Move focus to another tab

Posted on 2012-03-13
5
270 Views
Last Modified: 2012-03-13
Hi,

I am currently creating a screen with multiple tabs in vb.net and i would lime to be able to move the user to set the focus to different tabs so the user does not need to click on them.
Any help is appreciated.

Regards,

Rosd
0
Comment
Question by:ross13
5 Comments
 
LVL 8

Expert Comment

by:gpizzuto
ID: 37713475
what method will the user "use" ? Using TAB button, some function/key (F1..F12), some combination on keys... ???
0
 
LVL 11

Expert Comment

by:rowansmith
ID: 37713515
The following programatically selects select the TabPage called "tabPage2" which is one of the Tab in the TabControl tabControl1 and displays it in the tabControl.

tabControl1.SelectedIndex = tabControl1.TabPages.IndexOf(tabControl1.TabPages["tabPage2"]);

Open in new window


Hope that makes sense - alot of tabs....
0
 
LVL 11

Accepted Solution

by:
rowansmith earned 500 total points
ID: 37713524
Ooops, just realised I gave you the C# format, VB as follows:

TabControl1.SelectedIndex = TabControl1.TabPages.IndexOf(TabControl1.TabPages("tabPage2"))

Open in new window

0
 
LVL 40
ID: 37713924
I usually do it by letting the user press a function key (I display the function keys at the end of the text on each tab).

To be able to do that at the form level, you first need to set the KeyPreview property of the form to True, so that you will be able to catch all the keys that are pressed while the user is using the form.

Then, in the KeyUp event of the form, I trap the key and display the proper tab, calling it by its name. tacMain is the TabControl.

Private Sub FormMain_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp

'Implements a way to swicth tabs with the keyboard, since the TabControl
'	does not implements shortcut keys
  Select Case e.KeyCode
    Case Keys.F2 : tacMain.SelectedTab = tabProject
    Case Keys.F3 : tacMain.SelectedTab = tabMaterials
    Case Keys.F4 : tacMain.SelectedTab = tabInventory
    Case Keys.F5 : tacMain.SelectedTab = tabSmallParts
    Case Keys.F6 : tacMain.SelectedTab = tabDocumentation
    Case Keys.F7 : tacMain.SelectedTab = tabReports
  End Select

End Sub

Open in new window

0
 

Author Closing Comment

by:ross13
ID: 37715161
Cheers
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# application error "Parameter Is Not Valid". 3 79
C# Single Form 8 28
Javascript and Jquery not firing 9 42
What do you call this line of code in this .NET Core page? 4 27
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now