How can you create Alt shortcuts in a Windows Forms application?

前端 未结 3 2310
天涯浪人
天涯浪人 2021-02-20 09:48

I\'d like to create keyboard shortcuts for some controls in my Windows Forms application.

Example:

\"Screens

3条回答
  •  醉梦人生
    2021-02-20 10:14

    When the label receives focus from pressing its accelerator key (set using the &), it forwards the focus to the next control in the tab order, since labels are not editable. You need the textbox to be next control in the tab order.

    To view and correct the tab order of your form, use the View + Tab Order command in the IDE. Using TabPages or other containers adds a level of nesting to the tab order (e.g., 1.1, 1.2 instead of just 1 and 2), but if the label and textbox are within the same container it shouldn't be too hard to set properly.

提交回复
热议问题