操纵键盘输入 [英] Manipulating Keyboard Input

查看:107
本文介绍了操纵键盘输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好专家,

如何在编辑框内操作输入,
假设

当编辑框具有焦点,并且我们按一个键(例如字母"A")时,我希望将其显示为字母"B"而不是"A",

在所有不同的键盘事件中,这是操作此功能的最佳位置,我尝试了几次,但均未成功.

KeyDown,
KeyPress
KeyUp
PreviewKeyDown


请提出建议.

问候Prateek.

Hello Experts,

How can i manipulate the input inside a edit box,
let''s suppose,

when a edit box has a focus, and we press a key (say letter ''A''), i want it to be displayed as letter ''B'' instead of ''A'',

which is is the best place to manipulate this, among all different keyboard events, i tried it several places but no success.

KeyDown,
KeyPress
KeyUp
PreviewKeyDown


please suggest.

regards Prateek.

推荐答案

KeyPress会添加其他事件参数,以便您更好地分析键盘事件
KeyPress would do it has additional event arguments so you can better analyza keyboard events


嘿,最好的事件是KeyDown,在处理程序中只需取消KeyEventArgs,

Hey the best event is KeyDown, at handler just cancel KeyEventArgs,

private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            Keys k = (Keys)sender;
            if(k.GetType = Keys.A)
            e.Handled = false; // to check it to fulfill
            
            // Do as your wish
        }



希望对您有帮助..



Hope it would help you..


处理TextBoxTextChanged事件.


这篇关于操纵键盘输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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