accelerator keys

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard

    accelerator keys

    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?
  • Tian Min Huang

    #2
    RE: accelerator keys

    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_Sel ectedIndexChang ed(object sender,
    System.EventArg s e)
    {
    if(this.tabCont rol1.SelectedTa b.Text == "Tab1")
    {
    this.button1.Te xt = "&Button1";
    this.button2.Te xt = "Button2";
    }
    else
    {
    this.button1.Te xt = "Button1";
    this.button2.Te xt = "&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.

    Comment

    • Tian Min Huang

      #3
      RE: accelerator keys

      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_Sel ectedIndexChang ed(object sender,
      System.EventArg s e)
      {
      if(this.tabCont rol1.SelectedTa b.Text == "Tab1")
      {
      this.button1.Te xt = "&Button1";
      this.button2.Te xt = "Button2";
      }
      else
      {
      this.button1.Te xt = "Button1";
      this.button2.Te xt = "&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.

      Comment

      • Radek Cerny

        #4
        Re: accelerator keys

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

        "Tian Min Huang" <timhuang@onlin e.microsoft.com > wrote in message
        news:AXPPt22cDH A.2108@cpmsftng xa06.phx.gbl...[color=blue]
        > 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[/color]
        snippet:[color=blue]
        >
        > //-------------code snippet--------------------
        > private void tabControl1_Sel ectedIndexChang ed(object sender,
        > System.EventArg s e)
        > {
        > if(this.tabCont rol1.SelectedTa b.Text == "Tab1")
        > {
        > this.button1.Te xt = "&Button1";
        > this.button2.Te xt = "Button2";
        > }
        > else
        > {
        > this.button1.Te xt = "Button1";
        > this.button2.Te xt = "&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[/color]
        rights.[color=blue]
        >[/color]


        Comment

        Working...