Button Control

Button Control

Button control is used to perform some action. Action may be Save, Print, Add New, Modify, Delete, Exit, etc. Whenever the user clicks a button, the Click event handler is invoked.

You place code in the Click event handler to perform any action you desire.

The text displayed on the button is contained in the Text property. The Button control can also display images using the Image and ImageList properties .

Property : 

(1) Text : It is the text that is displayed on the button control. The Text property can contain an access key, which allows a user to “click” the control by pressing the ALT key with the access key. 

If youplaceampersand (&) before any letter, so underscore letter will appear, then user can press alter key with that letter to fire the Click event.

For example, when you set the E&xitin Text property of button control, it will be displayed as Exit. So by pressing the ALT key& x click event will be fired.

  1. Name
  2. BackColor
  3. ForeColor 
  4. AuotSize 
  5. Visible 
  6. Enabled 
  7. Left
  8. Right
  9. Top
  10. Bottom
  11. Margin
  12. Image
  13. ImageAlign
  14. TextAlign
  15. Size
  16. Location 
  17. Cursor 
  18. TabIndex
  19. TabStop
  20. Font

All above properties are discussed in previouscontrols.

Method :

All above methods are discussed in label control.

PerformClick : Generates a Click event for a button. This method raises the click event of the button control.

This method comes in handy when the code in the click event has to be executed even when the user has not clicked the button.

Event :

  1. Click
  2. DoubleClick
  3. MouseDown
  4. MouseUp
  5. MouseMove
  6. MouseWheel
  7. MouseEnter
  8. MouseLeave
  9. MouseClick
  10. MouseDoubleClick
  11. MouseHover
  12. TextChanged
  13. KeyPress
  14. KeyDown
  15. KeyUp
  16. Enter
  17. Leave
  18. GotFocus
  19. LostFocus
  20. Validating
  21. Validated