开发者

how to press [Enter] catch the Enter but not to Fall line?

how to press Enter - catch the Enter but no开发者_如何转开发t to Fall line ?

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#

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

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; }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜