CJ

The circle of life – ** .Net – Training – MOSS **

  • Past Post

  • Vistor Locations

WinForm button focus

Posted by Clayton James on January 18, 2007

Here are a couple of programmatic Key-Stroke tips for WinForm applications.

I had to set a button to have the focus whenever the Enter key was pressed after a user filled out some data entery.

In ASP.Net 2.0 you have the new property DefaultButton but what do you have in WinForms?

Form.AcceptButton (property)
Gets or sets the button on the form that is clicked when the user presses the ENTER key.
e.g. this.ParentForm.AcceptButton = searchButton;

 

You also have Form.CancelButton
Gets or sets the button control that is clicked when the user presses the ESC key.

 

Hope this saves some time 🙂

Advertisements

One Response to “WinForm button focus”

  1. Carmen said

    What you are giving us here is not some incredible new insight made possible by the advent of social media, but some basic rules on how to write effective press releases.

    http://allin1panel.com/blog/insider-secrets-social-media-marketing-discovered/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: