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]
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
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