如何按输入 - 捕捉Enter但不是Fall line?
例如,我有这个:
private void txtPlace_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
// do somthing
}
}
并且我不想掉线
我在Windows-Mobile上工作 - C#
提前致谢
答案 0 :(得分:2)
从这篇帖子中查看我的答案:
Check when arrow key are pressed
您必须将KeyPreview
事件激活为true才能收听您的按键事件
所以对你的问题:
Private Sub frm_YourForm(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
e.Handled = True
End If
End Sub
答案 1 :(得分:0)
尝试
if(e.KeyCode == Keys.Enter) { e.SuppressKeyPress = true; }