tehon3299 Posted January 6, 2003 Posted January 6, 2003 Hey - I was wondering how you can set a form so that when the user presses the 'ENTER' button, it will simulate them clicking a button on the form. For example, they input data into a textbox and hit enter instead of having to click the Submit buttom. Quote Thanks, Tehon
*Experts* Nerseus Posted January 6, 2003 *Experts* Posted January 6, 2003 Set the Form's AcceptButton property to a button control on the form. This won't work when some controls have focus, such as a multi-line TextBox. But then, you wouldn't want Enter to press a button in that case :) -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
tehon3299 Posted January 6, 2003 Author Posted January 6, 2003 There is no option on the form's properties for AcceptButton. I put frmExample. and the AcceptButton is not a property for it. Am I doing something wrong? The property is on the form and not the actual button right? Quote Thanks, Tehon
*Gurus* divil Posted January 6, 2003 *Gurus* Posted January 6, 2003 Set it in the designer. frmExample is the name of your form class, not an instance of the class itself so you won't be able to access any instance properties like that from code unless you actually have an instance to work with. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
tehon3299 Posted January 6, 2003 Author Posted January 6, 2003 Where in the designer do I set it? I remember in VB 6 there was a default button for the form, but I do not see where I set it in the designer in VB .NET. Thanks Quote Thanks, Tehon
*Gurus* divil Posted January 6, 2003 *Gurus* Posted January 6, 2003 You highlight the form itself (not the button) and there is an AcceptButton in the propertygrid. In the dropdown list for that property will be all the buttons on the form. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
tehon3299 Posted January 6, 2003 Author Posted January 6, 2003 (edited) Thanks a lot. Works perfect. Edited January 7, 2003 by tehon3299 Quote Thanks, Tehon
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.