Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Windows Forms n00b question about text boxes

OK, Windows apps are obviously more foreign to me than I thought. Is there some property I'm overlooking for text boxes that, when the user presses enter, will fire a particular button press?

3 Comments

  • or you can check the keypress event for the textbox and see if it was an enter key.

  • Except that at least in Win32 the enter key message will never be sent to the edit control unless it is created with ES_WANTRETURN style. I'm thinking .Net's message handling will not be much different from Win32's.

  • Actually Winforms Textboxen have a property to 'Accept Return' so that they will add a carriage return to the text in the box. Mainly used for multi-line text boxes. Other than that, you can check on keypress for the retrun key being hit.

Comments have been disabled for this content.