开发者

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

开发者 https://www.devze.com 2023-03-01 18:39 出处:网络
how to press Enter - catch the Enter but no开发者_如何转开发t to Fall line ? for example, i have this:

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

精彩评论

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

关注公众号