Access keys to access the TabPage

M

Muthu

Hello Group,

I need to have access keys to access the TabPage.

(e.g)
TabControl1 will have TabPage1, TabPage2, TabPage3.

I want to display the tab pages with the access keys under-lined as follows
TabPage1 TabPage&1 - Where 1 is the access key
TabPage2 TabPage&2 - Where 2 is the access key
TabPage3 TabPage&3 - Where 3 is the access key

What is the simple best way to achieve this.

thanks in advance

muthu
 
M

Muthu

Thanks. It worked.
----------------
Here is the C# code for the implementation
private void tabControl1_DrawItem(object sender,
System.Windows.Forms.DrawItemEventArgs e)
{
TabControl tcSender = sender as TabControl;
if( tcSender == null )
return;
TabPage tcPage = tcSender.TabPages[e.Index];
using ( StringFormat sf = new StringFormat())
{
sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
if( tcSender.SelectedIndex == e.Index)
e.Graphics.FillRectangle(SystemBrushes.Control, e.Bounds);
e.Graphics.DrawString(tcPage.Text, tcSender.Font,
SystemBrushes.ControlText, e.Bounds, sf);
}

}

protected override bool ProcessMnemonic(char charCode)
{
foreach (TabPage tp in this.tabControl1.TabPages)
{
if ( IsMnemonic( charCode, tp.Text ))
{
tabControl1.SelectedTab = tp;
return true;
}
}
return base.ProcessMnemonic (charCode);
}

muthu!

"Mick Doherty"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top