To move from one textbox field to another

I make my sample form with textboxes on it, and buttons as a control to add, edit, save, undo, delete & close form, just to study the behavior of this controls, setting the tab order too. But when i compile my form and run it, the cursor sticks at the first textbox field when I press the enter key, not if I use the tab key or mouse, Do we have to make a code for every textfield just to move to another textbox or other control?

thank you

[447 byte] By [Madix_t] at [2007-12-16]
# 1
Hi,
Yup, your quite right there. You must create a routine that sends a focus to other controls when you press the enter key. To do this easier, you could create an event that handles all of the Keypress events of your controls and just use sendkeys.sendwait("{TAB}"); to emulate the enter key as a tab key...

private void keypressHandler(object sender, KeyPressEventArgs e) {
if (e.KeyChar = Keys.Enter) {
SendKeys.SendWait("{TAB}");
}
}

cheers,
Paul June A. Domag

PaulDomag at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 2
Thanks Paul, I try it but it generate an error "Cannot implicitly convert 'char' to 'bool'...
Madix_t at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 3
Paul's code has a typo (was missing an equal sign) - I am pasting the correct code (fixing his original snip)

private void keypressHandler(object sender, KeyPressEventArgs e) {
if (e.KeyChar == Keys.Enter) {
SendKeys.SendWait("{TAB}");
}
}

Regards,
Saurabh Nandu
www.MasterCSharp.com
www.AksTech.com

SaurabhNandu at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 4
Hi,
Whew... Didn't catch that... THanks for correcting it though...Smile
cheers,
Paul June A. Domag
PaulDomag at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 5
thanks to both of you...now i got it workSmile
Madix_t at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 6
This would not work for me. I had to use (e.KeyChar == 13) because it would not compile. 13 is the char for the Enter key.
AZ17 at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...