我可以禁用对特定控件的键盘输入吗? [英] Can I disable keyboard input to a specific control?
本文介绍了我可以禁用对特定控件的键盘输入吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以禁用对控件的键盘输入?例如ListView
?我怎么做?我已经尝试覆盖KeyUp
KeyDown
事件,但是显然不是这样吗?
Is it possible to disable keyboard input to a control? For instance a ListView
? How do I do that? I've tried overriding the KeyUp
KeyDown
events but apparently that was not the way?
IsEnabled
是一个很好的解决方案,但是我只希望禁用键盘交互功能并保持鼠标交互功能不变.
IsEnabled
is a good solution, however I only wish to disable keyboard interaction and leave mouse interaction intact.
推荐答案
Handling the KeyDown
event is too late, but you can handle the PreviewKeyDown event and that should give you the behavior you are looking for:
private void MyListBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
e.Handled = true;
}
这篇关于我可以禁用对特定控件的键盘输入吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文