Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I tried the same code but my text is getting clear on pressing enter button for moving next textbox

What I have tried:

private void txtProductName_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode ==Keys.Enter)
{

Cbounit.Focus();
}
}
Posted
Updated 26-Jan-19 4:16am
v2
Comments
Richard MacCutchan 26-Jan-19 9:58am    
Why not just set tab order and use the default TAB key for moving between controls?
[no name] 26-Jan-19 10:04am    
on tab press its working,but i want on enter button
Richard MacCutchan 26-Jan-19 10:06am    
In that case, please edit your question (use the Improve question link above), and add full details of what the problem is and where it occurs.
[no name] 26-Jan-19 10:07am    
ok

1 solution

Don't do that. As Richard suggests, the TAB key is the normal "movement-between-inputs" key, ENTER is "I've filled it in, now process it" key.

And while it is possible to do what you want, it's a bad idea as it makes your app incompatible with nearly all other apps in Windows - which means your method will either be forgotten, or will actively annoy users.
Always stick to standards - they are there for a reason!

Setting the tab order is easy: in the designer you just click the Tab Order button or select it from the View menu. You then click on the controls in the order they should be entered (remembering to click the relevant label before the control it refers to). When you are done, just click the button again.
 
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