如何在一个控件中使Tab键作为一般的输入键来触发KeyDown,KeyUp事件呢?

在一个控件中使Tab键作为一般的输入键来触发KeyDown,KeyUp事件,需要自定义一个新控件 ,然后重写IsInputKey 方法
using System;
using System.Windows.Forms;
public class MyTextBox :System.Windows.Forms.TextBox
{
// Override IsInputKey method to identify the Special keys
protected override bool IsInputKey( System.Windows.Forms.Keys keyData )
{
switch ( keyData)
{
// Add the list of special keys that you want to handle
case Keys.Tab:
return true;
default:
return base.IsInputKey(keyData);
}
}
}
就是这样做,这样就按Tab键就可以触发KeyDown,KeyUp事件了!
原文地址:https://www.cnblogs.com/xuefeng1982/p/1489385.html