[英]how to press [Enter] catch the Enter but not to Fall line?
how to press Enter - catch the Enter but not to Fall line?如何按Enter - 抓住 Enter 而不是 Fall 线?
for example, i have this:例如,我有这个:
private void txtPlace_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
// do somthing
}
}
and i don't want to Fall line我不想掉线
i work on Windows-Mobile - C#我在 Windows-Mobile 上工作 - C#
thanks in advance提前致谢
Checkout my answer from this Post:从这篇文章中查看我的答案:
Check when arrow key are pressed 检查何时按下箭头键
You have to activate your KeyPreview
event to true to listen to your keypress Event您必须将
KeyPreview
事件激活为 true 才能收听您的按键事件
So for your problem:所以对于你的问题:
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
Try尝试
if (e.KeyCode == Keys.Enter) { e.SuppressKeyPress = true; if (e.KeyCode == Keys.Enter) { e.SuppressKeyPress = true; }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.