Previous | Home | Next |
The button control exists on just about any Windows dialog you can think of. A button is primarily used to perform three kinds of tasks:
For closing a dialog with a state (for example, OK and Cancel buttons) For performing an action on data entered on a dialog (for example clicking Search after entering some search criteria) For opening another dialog or application (for example, Help buttons)
Properties of Button Control
Name | Availability | Description |
FlatStyle | Read/Write | If you set the style to PopUp, the button will appear flat until the user moves the mouse pointer over it. When that happens, the button pops up to its normal 3D look. |
Enabled | Read/Write | Enabled property to false means that the button becomes grayed out and nothing happens when you click it. |
Image | Read/Write | Allow you to specify an image (bitmap, icon etc.), which will be displayed on the button. |
ImageAlign | Read/Write | With this property, you can set where the image on the button should appear. |
FlatStyle | Read/Write | did. |
Button Events
The most used event of a Button is the Click event. This occurs whenever a user clicks the button, by which we mean pressing the left mouse button and releasing it again while over the button. This means that if you left-click on the button and then draw the mouse away from the button before releasing it the Click event will not be raised. Also, the Click event is raised when the button has focus and the user press Enter. If you have a button on a form, you should always handle this event.