Click here to Skip to main content
15,889,096 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i'm working on win form where i have 58 text box to be filled in.

what i need is a single method to get focus from one text box to another by enter button.

till now i tried, google for search and used my prv. method

C#
private void cmbTc1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                cmbDivision.Focus();
        }


also

C#
private void cmbTc1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{TAB}");
        }


but this time the no. of text box very much. so need single method.

Help
Posted
Updated 28-Oct-12 20:02pm
v2
Comments
Sergey Alexandrovich Kryukov 29-Oct-12 1:58am    
Not a question; the problem is not clear at all. Do a single method, please.
--SA
sachees123 29-Oct-12 2:14am    
sry 4 that,
see, a data entry operator is more friendly with enter button. one way for me is to write the code for each and every text box and give its focus to another text box. it was perfect when i have 5 to 8 text box with me. now the fig. goes to 58. thats why i need a single mthod to control all text box. I hope now the problem is clear to you.

1 solution

Use the TextBox.TabIndex[^] property. The way you wanted to move from one textbox to another. just increase the number start from 1 to 58.

Don't use the enter key when you have tab key.
 
Share this answer
 
v2
Comments
sachees123 29-Oct-12 2:07am    
tab index is set as said. but dont want to use tab button for moving from one textbox to another. see, a data entry operator is more friendly with enter button. thats why i need single method for movement.

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