Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i know enter key is pressed on leave event of combobox or textbox in c#
Posted
Comments
Sergey Alexandrovich Kryukov 6-Jul-11 3:31am    
Not clear. What does it mean? Please explain the event sequence.
Yes, I see you already got some answers, but it does not make your question clear to me.
--SA

You'd have to catch the keypress itself, not try to work it out in the leave event.
 
Share this answer
 
C#
protected override bool ProcessDialogKey(Keys keyData)
{
   switch (keyData)
   {
      case Keys.Enter:
      case Keys.Space:
         return base.ProcessDialogKey(Keys.Tab);
   }
   return base.ProcessDialogKey(keyData);
}



i think this link[^]will help you
 
Share this answer
 
Comments
mayur csharp G 6-Jul-11 3:36am    
no not like
Actually i am doing something on leave event of textbox as my control goes to next control on enter key in my whole application but it should be execute only on leave event and when enter key is pressed
depending on your specific requirement
this can help you:

http://stackoverflow.com/questions/5605561/navigation-in-winforms-using-enter-key[^]
 
Share this 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