Using access key to navigate tabs in a tab control

  • Thread starter Thread starter Ed
  • Start date Start date
E

Ed

Hi,
I'm new .NET & C#. I have to do a form which has a tab control with 4
tabs.
I want to be able to switch between these tabs with an access key.
MSDN says that the '&' in a text of a button or label will enable an
access key. But MSDN says this is not allowed for tab control.

Is there any other wasy by which I can accomplish this??

Thanks in advance
Ed
 
* (e-mail address removed) (Ed) scripsit:
I'm new .NET & C#. I have to do a form which has a tab control with 4
tabs.
I want to be able to switch between these tabs with an access key.
MSDN says that the '&' in a text of a button or label will enable an
access key. But MSDN says this is not allowed for tab control.

The standard tabcontrol doesn't support that. If you have a look at the
tabcontrol used in many Windows dialogs, you won't see any mnemonics
assigned to the tabs.
 
Ed,

If you are up to it, here is some suggestion on how this could be done:

In a TabControl derived class, override this:

protected override bool ProcessMnemonic(char charCode)

{

foreach(Control child in this.Controls)

{

if(IsMnemonic(charCode, child.Text))

{

if(child is TabPage)

{

this.SelectedTab = child as TabPage;

return true;

}

}



}

return false;

}



You should of course specify a text with a "&" for the tab pages.



Also, Essential Tools from Syncfusion provides an advanced tab control with
this feature built-in, among other cool things, take a look at it here
(under the Tabs Package section):



http://www.syncfusion.com/Products/tools.aspx



Regards,
Praveen Ramesh
Syncfusion, Inc.
visit www.syncfusion.com for .Net Essentials
 
Handle the KeyDown event on the tab control and based on your access key,
select the corresponding page. But this will work only when the Tab Control
has focus.

-vJ
 
Back
Top