问题描述
ListView.KeyDown <按Ctrl>
事件显示以下内容:
ListView.KeyDown <Ctrl>
event shows the following:
e KeyData = LButton | ShiftKey | Control
base {KeyData = LButton | ShiftKey | Control}
Alt false bool
Control true bool
Handled false bool
KeyCode LButton | ShiftKey
KeyData LButton | ShiftKey | Control
KeyValue 17
Modifiers
Shift false bool
SuppressKeyPress false bool
我不喜欢的事实,&LT;&Shift键GT;
被显示出来,但控制键被显示出来。
在ListView.KeyUp &LT;按Ctrl&GT;
事件显示以下内容:
I don't like the fact that the <ShiftKey>
is showing up but the Control key is showing up.On ListView.KeyUp <Ctrl>
event shows the following:
- e {KeyData = LButton | ShiftKey}
+ base {KeyData = LButton | ShiftKey}
Alt false bool
Control false bool
Handled false bool
KeyCode LButton | ShiftKey
KeyData LButton | ShiftKey
KeyValue 17
Modifiers None
Shift false bool
SuppressKeyPress false
是什么给了它的怪异。看在网上,看是否有此错误的任何实例,但可以找到什么。我已经试过了关键preVIEW设置为true托管形式无济于事的。
What gives it's weird. Look over the web to see if there are any examples of this error but could find nothing. I have tried setting the KeyPreview to true on the hosting form to no avail.
任何投入是值得欢迎的。
Any input is welcome.
推荐答案
这里没有错误时,你只需pressed并释放Ctrl键。调试器只是没有在键枚举转换为字符串非常好。它是由具有[旗]属性所以它试图在该值的各个比特映射到一个关键该枚举confuzzled
There's no error here, you simply pressed and released the Ctrl key. The debugger just isn't very good at converting the Keys enum to a string. It is confuzzled by that enum having the [Flags] attribute so it tries to map the individual bits in the value to a Key.
所以的KeyDown =(Keys.Control | Keys.ControlKey)= 0x20011。这调试轧液到结果地址0x20000 =控制结果
0x00010 = Shift键结果
0x00001 = LButton。
So KeyDown = (Keys.Control | Keys.ControlKey) = 0x20011. Which the debugger mangles to
0x20000 = Control
0x00010 = ShiftKey
0x00001 = LButton.
和KEYUP =(Keys.ControlKey)= 0x00011。这调试轧液到结果
0x00010 = Shift键结果
0x00001 = LButton。
And Keyup = (Keys.ControlKey) = 0x00011. Which the debugger mangles to
0x00010 = ShiftKey
0x00001 = LButton.
或者换句话说,无视调试器会告诉你。
Or in other words, ignore what the debugger tells you.
这篇关于ListView控件的KeyUp误差控制键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!