On Jul 13, 12:38 am, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
Rowe,
Do you have an idea how that would be done?
Cor
"ray well" <nos...@nospam.comschreef in berichtnews:eY**************@TK2MSFTNGP06.phx.gbl. ..
>>Ctrl+PageDown and Ctrl+PageUp are the standard Window's commands for
this.<<
seth,
thanks your reply.
but if u have a whole bunch of tab pages, it becomes a pain to have to go
thru all of them instead of going to the one u need directly.
ray
Do you have an idea how that would be done?
Of course I do!
Just start a new form and replace it's code behind with the below and
run the form. Presses Alt+1 will select the first page, Alt+2 selects
the second and Alt+3 will select the third tabpage. I would recommend
the OP inherit TabPage and add a new property for the keycode instead
of using Tag - but for sake of brevity I used Tag.
//////////////
Public Class Form1
Dim tabControl As New TabControl()
Public Sub New()
InitializeComponent()
Me.KeyPreview = True
TabControl.Name = "tabControl1"
For i As Integer = 1 To 3
Dim tabPage As New TabPage(String.Format("TabPage {0}",
i.ToString()))
'// Store the target keycode in the Tag property
'// A value of "D2, Alt" will select the control
'// when the user presses Alt+2
tabPage.Tag = String.Format("D{0}, Alt", i.ToString())
TabControl.TabPages.Add(tabPage)
Next
Me.Controls.Add(TabControl)
TabControl.Location = New Point(30, 30)
End Sub
Private Sub Form1_KeyUp(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
If e.Alt Then
For Each tabPage As TabPage In tabControl.TabPages
If tabPage.Tag.ToString() = e.KeyData.ToString() Then
tabControl.SelectedTab = tabPage
Exit For
End If
Next
End If
End Sub
End Class
////////////////////
Thanks,
Seth Rowe