textBox
-
hi all, am new to C# programming and i got a little problem am having some text boxes in my form, and i want the mouse cursor to move automatically to the next textBox when the user inputs data in the preceding textBox. Just like when you enter the WinXP serial, u don't have to click 'TAB' to move to next TextBox. thnx for ur help.
-
hi all, am new to C# programming and i got a little problem am having some text boxes in my form, and i want the mouse cursor to move automatically to the next textBox when the user inputs data in the preceding textBox. Just like when you enter the WinXP serial, u don't have to click 'TAB' to move to next TextBox. thnx for ur help.
You can subscribe to the KeyPress event and check if the textbox has got the required number of characters. If it has, you can move focus to the next textbox. Something like public void KeyPress_textBox1(...) { if (textBox1.TextLength == 5) { textBox2.SetFocus(); } } Regards Senthil My Blog
-
You can subscribe to the KeyPress event and check if the textbox has got the required number of characters. If it has, you can move focus to the next textbox. Something like public void KeyPress_textBox1(...) { if (textBox1.TextLength == 5) { textBox2.SetFocus(); } } Regards Senthil My Blog
thnx for ur help, one more thing, could I determine which data type could be entered in the text box, i.e. if the user entered "floating" no. for example it doesn't move the cursor. The user should enter "integer" for the cursor to move to the nexr text box.
-
thnx for ur help, one more thing, could I determine which data type could be entered in the text box, i.e. if the user entered "floating" no. for example it doesn't move the cursor. The user should enter "integer" for the cursor to move to the nexr text box.
You can use the Parse method on the Int32 class. Something like
... if (textBox1.Length == 5) try { Int32.Parse(textBox.Text); textBox2.Focus(); } catch(Exception) //Substitute correct exception { } }
Regards Senthil My Blog