473,385 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

TabPage Changing

i want a user to be able to change tab pages thru the keyboard, i tried
entering the TabPage.text as '&1 Names', "&2 Addresses', etc., so that the
user can change pages by type ALT 1, ALT 2, on the keyboard.

but the text showing up in the tab is '&1 Names' instead of the '1' being
underlined, and being able to be accessed thru the keyboard.

how can i get a user to be able to change from TabPage to TabPage thru the
keyboard? i find it hard to beleive it can't be done.

thanks,

ray
Jul 12 '07 #1
6 4546
On Jul 12, 12:28 pm, "ray well" <nos...@nospam.comwrote:
i want a user to be able to change tab pages thru the keyboard, i tried
entering the TabPage.text as '&1 Names', "&2 Addresses', etc., so that the
user can change pages by type ALT 1, ALT 2, on the keyboard.

but the text showing up in the tab is '&1 Names' instead of the '1' being
underlined, and being able to be accessed thru the keyboard.

how can i get a user to be able to change from TabPage to TabPage thru the
keyboard? i find it hard to beleive it can't be done.

thanks,

ray
Ctrl+PageDown and Ctrl+PageUp are the standard Window's commands for
this.

Also, you could moniter the keypress/keyup/keydown events for "alt 1"
and then change the tabpage via code.

Thanks,

Seth Rowe

Jul 12 '07 #2
>>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
Jul 12 '07 #3
The standard Windows.Forms.TabControl does not support this feature.

You can ownerdraw the TabControl to draw the tab text with the mnemonic and
then catch the mnemonics and change tabpage as appropriate.

You will find basic examples of this on my site:
http://www.dotnetrix.co.uk/tabcontrols.html

If you don't want to draw the tabs yourself (a lot of work especially with
Visual Styles), then you may like to use TabControlEx instead. This has
mnemonic support built in and also includes several other frequently
requested features.
http://www.dotnetrix.co.uk/controls.html

--
Mick Doherty
http://www.dotnetrix.co.uk/nothing.html
"ray well" <no****@nospam.comwrote in message
news:OQ*************@TK2MSFTNGP06.phx.gbl...
>i want a user to be able to change tab pages thru the keyboard, i tried
entering the TabPage.text as '&1 Names', "&2 Addresses', etc., so that the
user can change pages by type ALT 1, ALT 2, on the keyboard.

but the text showing up in the tab is '&1 Names' instead of the '1' being
underlined, and being able to be accessed thru the keyboard.

how can i get a user to be able to change from TabPage to TabPage thru the
keyboard? i find it hard to beleive it can't be done.

thanks,

ray


Jul 12 '07 #4
On Jul 12, 2:20 pm, "ray well" <nos...@nospam.comwrote:
>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
Like I said, you can watch the keyevents and then code in the
functionality for switching to a certain tab.

Thanks,

Seth Rowe

Jul 12 '07 #5
Rowe,

Do you have an idea how that would be done?

Cor

"ray well" <no****@nospam.comschreef in bericht
news: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


Jul 13 '07 #6
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

Jul 13 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: TMB333 | last post by:
I've researched as much as I can on the issue, but I've not found any clearly defined statement that acknowledges that the Hide method for a TabPage object just doesn't do what it's supposed to do....
2
by: JG | last post by:
Hi, I have a windows form with a TabControl on it. It has 3 tabpages on it. I have also coded a button that is supposed to 'add' a new tabpage. The code in that clicked event looks like this:...
1
by: RA | last post by:
Hi 1) I want to create a TabPage class in design mode - how do I do it? What type of project should I use? Is it going to be a custom control? 2) I have a TabControl that I would like to add to...
3
by: Cynthia | last post by:
I knew that "Hide" doesn't work with Tabpage if I want to hide it. I should use Remove/Add. But I have some other controls in the tabpage which I don't want to use code to dynamiclly create them....
8
by: touf | last post by:
Hi, I've a tabcontrol that contains many similar tabpages (exactly the same structure with different information), the tabpages number isn't known in the design time it depends of the data. Is...
8
by: Andre Nogueira | last post by:
Hi there. I would like to know it is possible in VB.Net 2003 to see that a user has clicked a tab page. My goal is to close the tab page if the user clicks a tabpage "separator" (not sure how to...
4
by: Ratan | last post by:
I have a form that has a tabcontrol with 5 tabpages. i want to rename the tabpages in runtime. Actually i want to right click the tabpage i want to rename and edit the text there itself. How to...
6
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hello gurus, I want to have a Form with a TabControl, this TabControl will contain TabPage that has controls in it, this TabPage is prepared at design time. I want in runtime to duplicate the...
3
vavc1980
by: vavc1980 | last post by:
Hello, I'm working on a windows application with C#, I reorganized a screen using the TabControl with 3 TabPages. Here's my problem, when I want to do something (printing, reading, etc)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.