Winform 控件添加事件
/// <summary>
/// 添加按钮上鼠标 移入、移出、按下、弹起 事件
/// </summary>
/// <param name="btn">操作的按钮</param>
private void AddBtnEvent(Button btn)
{
btn.MouseEnter += delegate (object sender, EventArgs e)
{
((Button)sender).BackgroundImage = Resources.btnMouseEnter;
};
btn.MouseLeave += delegate (object sender, EventArgs e)
{
((Button)sender).BackgroundImage = Resources.btnMouseLeave;
};
btn.MouseDown += delegate (object sender, MouseEventArgs e)
{
((Button)sender).BackgroundImage = Resources.btnMouseDown
};
btn.MouseUp += delegate (object sender, MouseEventArgs e)
{
((Button)sender).BackgroundImage = Resources.btnMouseUp;
};
}