Click here to Skip to main content
15,921,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want to handle by code the behavior of the tab key when user clicks it on a CombBox and TextBox,
I tried to catch it on KeyUp and KeyDown events of ComboBox, but I couldn't!!
Can any one help me plz, thx...
Posted

Do this is PreviewKeyDown event. That's all it takes.
VB
If e.KeyCode = Keys.Tab Then
  e.IsInputKey = True
End If
 
Share this answer
 
v2
Comments
saleem_deek 23-Aug-11 9:25am    
Thx a lot, this is the answer :D
saleem_deek 23-Aug-11 9:39am    
But can you tell me how to stop the normal Tab key behavior?
it's still going from control to another when I click on Tab and I want to stop it!
Prerak Patel 24-Aug-11 0:31am    
Updated the answer. Use e.IsInputKey = True
Set Form.KeyPreview to true and handle the Key events at the form level.
 
Share this answer
 
Comments
saleem_deek 23-Aug-11 6:24am    
I'm sorry but I didn't really understand, what do you mean by "form level" ?!
[no name] 23-Aug-11 6:31am    
Instead of handling TextBox.KeyDown, handle Form.KeyDown.

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