Solved

Move focus to another tab

Posted on 2012-03-13
5
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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