Click here to Skip to main content
15,748,748 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I want to get focus from one text box to another using keyboard keys not by mouse click .so I wrote the code but it doesn't work. It shows some error. The code is:
private void keypressHandler(object sender, KeyPressEventArgs e) {
if (e.KeyChar == Keys.Enter) {

The error I get is:
operator==cannot be applied to operands of type 'char' and"

How can I remove the error? If it's a wrong way then give correct code.
Updated 21-Nov-10 22:56pm

1 solution

Instead of 'e.KeyChar == Keys.Enter' try:
e.KeyChar == 11

See this page for details: KeyChar values[^]

Thus, something like:
if (e.KeyChar.Equals(Convert.ToChar(11)))
Share this answer
Dalek Dave 22-Nov-10 5:07am    
Good Call.
Toniyo Jackson 22-Nov-10 5:33am    
Good answer
shakil0304003 22-Nov-10 5:52am    
Good Answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900