Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I like to do something if i press enter in a textfield.. so i found this code:

 

if(e.KeyChar = Chr(Keys.Enter)){

//my things...

}

 

But that doesn wordk.. he doesnt know the .keychar and the Chr...

Why not ?????

 

Or is this for the normal C# and not for C#.Net ??

How to change ?

 

Thanx,

Jelmer

  • Administrators
Posted

Is this for a windows or web application? Could you clarify what you mean by

doesnt know the .keychar and the Chr
are you getting errors at compile time or runtime - what are the errors?

 

Also if you are using C# then Chr won't work as that is a VB keyword.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

KeyChar is only available in the KeyPress event not the KeyUp or KeyDown events. To check if key char is enter then you can do...

if(e.KeyChar == (char)Keys.Enter) {
}

For any more help you'll have to answer PlausiblyDamps questions.

Anybody looking for a graduate programmer (Midlands, England)?
  • Leaders
Posted
Also, if you consumer the keypress for the enter key (the control reacts to it), make sure that you set e.Handled to true to avoid giving the user an error beep.
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...