窗体窗口上的热键 [英] hotkeys on form windows

查看:105
本文介绍了窗体窗口上的热键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文本框的表单:txtb1和txtb2.
通过以下功能,我可以更改按钮之间的焦点.当我按ALT + 1时txtb1文本框会得到焦点,而当我按ALT + 2时
焦点转到txtb2 TEXTBOX.

我首先需要将表单的keypreview设置为true.

I have form with two TEXTBOX: txtb1 and txtb2.
whith the following function I change the focus between the buttons. when I press ALT+1 the txtb1 TEXTBOX get the focus and when I press ALT+2 the
focus go to txtb2 TEXTBOX.

I first need to set the keypreview of the form to true.

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If Control.ModifierKeys = Keys.Alt Then
            If e.KeyCode = Keys.D1 Then
                TextBox1.Focus()
            ElseIf e.KeyCode = Keys.D2 Then
                TextBox2.Focus()
            End If
        End If
    End Sub




如果表单有菜单条,则此功能不起作用.




this function doesn''t work if the form have a menustrip.
are there option to disable the alt in the menustrip?

推荐答案

否,所有Windows窗体均使用此行为,请尝试使用其他键或组合键.
Ctrl + Alt + 1或Ctrl + 1
No, all windows forms uses this behavior, try to use another key or a cambination.
Ctrl+Alt+1 or Ctrl+1


这篇关于窗体窗口上的热键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆