private void FrmItemDetailsAdd_KeyDown(object sender, KeyEventArgs e)
{
string keyCode = e.KeyCode.ToString();
switch (keyCode)
{
case "Enter":
case "Return":
if (this.ActiveControl is TextBox)
{
if (!((TextBox)this.ActiveControl).Multiline)
{
SendKeys.Send("{TAB}");
}
}
break;
}
switch (e.KeyValue)
{
case 116:
// 点击了F5按钮
this.FormOnLoad();
break;
}
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.F5)
{
this.FormOnLoad();
}
if ((!(ActiveControl is Button)) &&
(keyData == Keys.Up || keyData == Keys.Down || keyData == Keys.Enter))
{
if (keyData == Keys.Enter)
{
System.Windows.Forms.SendKeys.Send("{TAB}");
return true;
}
if (keyData == Keys.Down)
{
System.Windows.Forms.SendKeys.Send("{TAB}");
}
else
{
SendKeys.Send("+{Tab}");
}
return true;
}
else
{
return base.ProcessCmdKey(ref msg, keyData);
}
}