Question Default Enter Key Behaviour

stevecurrey

New member
Joined
Sep 17, 2008
Messages
2
Programming Experience
Beginner
Hi all - first of all a hello from a new member :)

I have a really strange one here! I have a windows form with no default accept or cancel button. I have a tab container and a multi line textbox on a tab control. On my dev machine, pressing enter or return will create a new line in the textbox. On all other machines, it seems to fire the button click event of my cancel button.

It's really strange that it runs fine on my dev machine but not on any of the clients. The workaround is ctrl + enter / return but obviously I want to sort this out.

I'd be grateful for any ideas!

Thanks in advance,

Stephen.
 
Try un-setting the Accept button property on the form, then for all of the controls except the multi-line TB's use the KeyUp event to check for the enter keycode and call the button's PerformClick() method from there.

VS 2003 has a few issues with things like MultiLine TB's and using the Form's AcceptButton property.
 
Hi there is no accept button property for the form - that's why it's confusing the hell out of me! :(

I just want the enter key to do a line return in the multi-line text box.
 
If there's no 'AcceptButton' set for the form, then the multi line textbox does do a 'new line'.

Do you have any code in the TB's KeyDown, KeyPress and/or the KeyUp events?
 
Are you sure the focus is still in the textbox when they click enter? Sounds like the focus might be moving to your cancel button somehow.
 
Back
Top