Solved

Move focus to another tab

Posted on 2012-03-13
5
269 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

11 Experts available now in Live!

Get 1:1 Help Now