Hi CSharp Good Guys,
Need your help. Please help me. I am using C#Net2008 for Window application.
On the FORM there are 14 TextBox Controls. The Users are requesting that after data input in a textbox, they press ENTER key they expect the cursor to move to the next TextBox whose TabIndex is just 1 greater than the current one. So far, the TAB key does work but ENTER key is not.
Please share your suggestion with me and if possible share with me a sample coding. I rather learn and understand coding logic.
Thank You.
Loading

Jaish MathewsRank #225 · 11K reputationPosted Apr 15, 2010, 4:55 AM EDT
Do below things
if (e.KeyCode.Equals(Keys.Enter))
{
SendKeys.Send("{TAB}");
}
Just programmatically firing a TAB key, once enter press. If your TAB correct, this will work.
Sam HobbsRank #107 · 20.5K reputationPosted Apr 15, 2010, 1:06 PM EDT
If you need to not advance for some controls, then we need to add logic to that function for that. For example, if the current control (the control with focus) is a button, and if you want the enter key to click the button as normally happens, then we need to add logic for that.
Also, if the form has an Okay button then the ProcessCmdKey can prevent the enter key from doing the equivalent of clicking the Okay button. This might be an advantage or a disadvantage, but I assume that if it is intended that the enter key be equivalent to clicking the Okay button, then that can be done too.
Sam HobbsRank #107 · 20.5K reputationPosted Apr 16, 2010, 2:37 PM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Apr 16, 2010, 2:41 PM EDT