Page Stats
Visitor: 220
Button Control in C#.Net
Button is commonly used to execute code when it is clicked. Usually the Click event is handled for the Button.
Properties | Description |
---|---|
AutoEllipsis | Specifies whether to append dots (...) when the text in the button is too long. |
DoubleClick | When the control is double-clicked. |
Enter | Control got focus or active. |
Leave | Control lost focus or no longer active. |
KeyDown, KeyPress, KeyUp | Keyboard Events. |
MouseDown, MouseEnter, MouseHover, MouseLeave, MouseMove, MouseUp | Mouse Events. |
TextChanged | Event raised when the value of the text changed. |
Validated | |
Validating |
Methods | Description |
---|---|
AutoSize | Specifies whether the button will automatically resize to fit its content. |
FlatStyle | Determines the style of the button. |
Enabled | If set to false, the button cannot be clicked. |
Image | An image that you can place inside the control. |
ImageAlign | The alignment of the image in the button. |
Text | The caption inside the button. |
Visible | Tells whether the button is visible or not. |
Events | Description |
---|---|
Click | Occurs when you click the button. |
Enter | Occurs when the control becomes active. |
Leave | Occurs when the control becomes inactive anymore. |
LocationChanged | Occurs when the location of the button is changed. |
MouseDown | Occurs when the mouse pointer is in the button and the mouse button is pressed down. |
MouseEnter | Occurs when the mouse enters the button. |
MouseHover | Occurs when the mouse stays stationary in the button for an amount of time. |
MouseUp | Occurs when you pressed the button and you let go of the mouse button. |
MouseLeave | Occurs when the mouse pointer leaves the button. |
Example 1: Add two Numbers.

Exercise 1: Perform Addition, Multiplication, Division, Subtraction

Exercise 2: Compare 2 input string using boxing and unboxing