1)The Event handling is nothing but executing some code whenever the user performs an action.
2)The Required code is to be return in a special method the method is that called as "Event handler".
3)The Event handler should be define in the Form class.
Syntax:
private void btnAdd_Click(object sender, EventArgs e)
{
//write your code here
}
Note1: 1)"btnAdd" is the control name
2)"Click" is the Event name
Note2: 1)sender: sender represents the control based on which the Events raised.
2)e: The "e" contains some additional info about the Event for example in mouse Click event the position of the mouse will be represented where it is clicked.
Example:
Steps:
1)Goto button control properties
2)Goto events
3)Double click on "Mouse Enter Event"
4)write below code
private void button1_MouseEnter(object sender, EventArgs e)
{
button1.BackColor = Color.DarkRed;
button1.ForeColor = Color.PowderBlue;
}
shown below figures:
.Above figure shows form with button
.Above figure shows form with Mouse Enter event fire(change the button color)
I hope this code will help you.
2)The Required code is to be return in a special method the method is that called as "Event handler".
3)The Event handler should be define in the Form class.
Syntax:
private void btnAdd_Click(object sender, EventArgs e)
{
//write your code here
}
Note1: 1)"btnAdd" is the control name
2)"Click" is the Event name
Note2: 1)sender: sender represents the control based on which the Events raised.
2)e: The "e" contains some additional info about the Event for example in mouse Click event the position of the mouse will be represented where it is clicked.
Example:
Steps:
1)Goto button control properties
2)Goto events
3)Double click on "Mouse Enter Event"
4)write below code
private void button1_MouseEnter(object sender, EventArgs e)
{
button1.BackColor = Color.DarkRed;
button1.ForeColor = Color.PowderBlue;
}
shown below figures:
.Above figure shows form with button
.Above figure shows form with Mouse Enter event fire(change the button color)
I hope this code will help you.