我正在使用它来允许光标前进到下TextBox一个WinForm:
private void GoToNextControl(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
{
this.SelectNextControl((Control)sender, true, true, true, true);
}
}
Run Code Online (Sandbox Code Playgroud)
如果不按"输入"时的"叮"声,这可以完美地工作.我怎么能"沉默"丁?
设置SuppressKeyPress到true在处理程序应该这样做:
private void GoToNextControl(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
{
this.SelectNextControl((Control)sender, true, true, true, true);
e.SuppressKeyPress = true;
}
}
Run Code Online (Sandbox Code Playgroud)
确保您的处理程序与KeyDown事件挂钩,因为这不起作用KeyUp.