Sir, I have about 20 textBoxe ,10 comboBox and 5 dateTimePicker in a form.
as I want to go cursor downward through each textbox whenever I press 'Enter' Key.
I coded:-
if(e.KeyCode==Keys.Enter)
{
txtLastName.Focus()// goes from txtFirstName to txtLastName
}
I am tired of writing this code in each textBox of my form.
is there an unique code to define these function in a form, i.e keydown event defines for 25 textboxes.?
Loading


Jignesh TrivediRank #16 · 50.3K reputationPosted May 29, 2013, 7:08 PM EDT
hi,
Please refer followinf link it might help you.
http://www.codeproject.com/Articles/13109/Redirect-the-Enter-key-from-a-Windows-Forms-TextBo
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.selectnextcontrol%28v=vs.100%29.aspx
SUNIL GUTTARank #1,832 · 810 reputationPosted Jul 2, 2013, 11:55 AM EDT
As you are dealing with enter key i.e we have 2 create a event handler for it and go proceed using foreach loop with sender(un-boxng) & focus method for next textbox in orderly fashion ..
Kunal VaishyaRank #990 · 2K reputationPosted Jul 2, 2013, 8:43 PM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Jul 2, 2013, 8:59 PM EDT
http://stackoverflow.com/questions/5605561/navigation-in-windows-forms-using-enter-key