本文介绍了C#键盘事件处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
—SA
Create some method implementing the action and call if and call if from different event handler. And yes, don''t use Designer, add all event handlers to event invocation list ("+=" operator) in code.
—SA
我有一个按钮数组,每个按钮都带有一个单击的事件处理程序((使用(按钮)发送程序进行编程)).我想以这样的方式使用键盘,即所按下的键与单击按钮时的作用相同! 如何在不重写事件的情况下执行此操作? (看到按钮单击是一个事件处理程序,而按下按键是一个键事件处理程序).
I Have an array of buttons with an event handler on click for each button ((programmed using (Button) sender )). I want to use the keyboard in such way that the key pressed do the same thing as if a button was clicked! How to do this without rewriting the event? (seeing that the button click is an eventhandler and the key press is a keyeventhandler)
推荐答案创建一些实现该操作的方法,并从不同的事件处理程序中调用if和if .是的,不要使用Designer,而是将所有事件处理程序添加到代码中的事件调用列表("+ ="运算符)中.
浏览此- keyboard-keys-visual-basic-net [ ^ ] Go through this- keyboard-keys-visual-basic-net[^]
如果您不介意使用组合键,请尝试将快捷键映射到按钮. 为此,只需在按钮的标题中放入amersand(&").这将使下一个字母对"Alt" +字母作出反应. 例如.如果您有一个按钮"Do Something",则将其标题设置为"Do So&mething",然后按"ALT" +"M"即可. If you don''t mind using a combination of keys, try mapping shortcut keys to the buttons. To do so, just put an amersand ("&") in the button''s caption. That will make the next letter to react to "Alt" + Letter. E.g. if you have a button "Do Something", make it''s caption "Do So&mething" and it will get pressed by "ALT" + "M".
更多推荐
C#键盘事件处理
发布评论