日期:2014-05-19  浏览次数:20788 次

求教键盘事件
我自己做了一个usercontrol,添加了一个基于usercontrol的键盘事件,但是在form   中使用这个控件的时候却键盘事件,这是为什么?求各位帮忙解答

------解决方案--------------------
protected override bool IsInputKey(Keys keyData) {
2.
/* 這裡需回傳true, 否則無法接收到方向鍵
3.
* MSDN:
4.
* Call the IsInputKey method to determine whether the key specified by the keyData
5.
* parameter is an input key that the control wants.
6.
* This method is called during window message preprocessing to determine whether
7.
* the specified input key should be preprocessed or sent directly to the control.
8.
* If IsInputKey returns true, the specified key is sent directly to the control.
9.
* If IsInputKey returns false, the specified key is preprocessed and only sent to
10.
* the control if it is not consumed by the preprocessing phase.
11.
* Keys that are preprocessed include the TAB, RETURN, ESCAPE, and the UP ARROW,
12.
* DOWN ARROW, LEFT ARROW, and RIGHT ARROW keys. */
13.
return true;
14.
}