日期:2014-05-18 浏览次数:21029 次
private void textbox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Enter) { e.SuppressKeyPress = true; System.Windows.Forms.SendKeys.Send("{Tab}"); } if (e.KeyCode == Keys.Up) { e.SuppressKeyPress = true; System.Windows.Forms.SendKeys.Send("+{Tab}"); } }
------解决方案--------------------
还是有简便的方法的。
仅需在母窗体类上加入:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { Keys key = (keyData & Keys.KeyCode); if (key == Keys.Down) { SendKeys.Send("{Tab}"); return true; } return base.ProcessCmdKey(ref msg, keyData); }