How to make cursor jump to the next text field
-
Hi, I'd like to make a cursor jump to the next text field when a user reach to the max length of the other in C# .Net. Ex: when you enter the key code for software installation, the cursor keeps go to the next text field without using the tab button. I'm a beginner for VS. Please help thanks. Kyah:doh:
-
Hi, I'd like to make a cursor jump to the next text field when a user reach to the max length of the other in C# .Net. Ex: when you enter the key code for software installation, the cursor keeps go to the next text field without using the tab button. I'm a beginner for VS. Please help thanks. Kyah:doh:
Step 1. On the form, set the KeyPreview property to true. Step 2. Make sure that the TabIndex is correct for each TextBox that will have this feature. Step 3. Add a KeyUp event for each of the TextBox controls. You can make one function, and assign the same function to each of the TextBox controls. Note that in my example, I have have named my function SSNTextBox_KeyUp. In my program, I have three Textbox controls, used for entering a Social Security number. Step 4. Write the KeyUp event function as follows:
private void SSNTextBox_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { if (((TextBox)sender).Text.Length == ((TextBox)sender).MaxLength) { SendKeys.Send("{TAB}"); } }
I hope this helps. Roy. -- modified at 21:42 Thursday 9th March, 2006 -
Hi, I'd like to make a cursor jump to the next text field when a user reach to the max length of the other in C# .Net. Ex: when you enter the key code for software installation, the cursor keeps go to the next text field without using the tab button. I'm a beginner for VS. Please help thanks. Kyah:doh:
Instead of using the SendKeys.Send method as suggested by Roy you can and in my opinion should use the Control.SelectNextControl method[^].
-
Hi, I'd like to make a cursor jump to the next text field when a user reach to the max length of the other in C# .Net. Ex: when you enter the key code for software installation, the cursor keeps go to the next text field without using the tab button. I'm a beginner for VS. Please help thanks. Kyah:doh: