accelerator keys

R

Richard

Is there a way to duplicate the accelerator key for
controls which live on separate pages of a tab control.
i.e. to have a button called &Button1 on one tab and
another button called &Button2 on another tab, both
buttons have Alt-B as their accelerator?
 
T

Tian Min Huang

Hi Richard,

Thanks for your post.

Based on my experience and research, an accelerator key can only be mapped
to a control, other controls with the same accelerator will not take
effect. To work around this problem, I suggest that you can dynamically
chage the Text of the controls. Please refer to the following code snippet:

//-------------code snippet--------------------
private void tabControl1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
if(this.tabControl1.SelectedTab.Text == "Tab1")
{
this.button1.Text = "&Button1";
this.button2.Text = "Button2";
}
else
{
this.button1.Text = "Button1";
this.button2.Text = "&Button2";
}
}
//---------------end of----------------------------

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.
 
R

Radek Cerny

Maybe this could be looked at as a feature request for future versions. It
would seem a reasonable thing to do - ignore invisible accelerators.
 

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

Similar Threads

Accelerator keys 3
Accelerator or Access Key 2
Accelerator Keys 1
Accelerator Keys? 2
Pressing Esc to make a form disappear 6
accelerator Keys 5
why is not Color.FromArgb working 4
Accelerators 7

Top