C# 克隆 MouseHover/MouseLeave 适用于原始控件而不是当前控件

C# cloned MouseHover/MouseLeave applies to original control & not current

我有一个表单,我 在面板中添加控件

one of them is a PictureBox holds a MouseHover/MouseLeave event like this

void PropAction_pBoxMouseLeave(object sender, EventArgs e)
{
    PropAction_pBox.ImageLocation = @"PicButtons\PropertiesBtn2.png";
}
void PropAction_pBoxMouseHover(object sender, EventArgs e)
{
    PropAction_pBox.ImageLocation = @"PicButtons\PropertiesBtn2White.png";
}

在添加按钮中我有这个代码

create a new button based on the newPropAction (original) and add it in a list *

" newPropAction_pBox represents the new PictureBox & PropAction_pBox represents the original PictureBox "*

        PictureBox newPropAction_pBox = new PictureBox();
        newPropAction_pBox.Image = PropAction_pBox.Image;
        newPropAction_pBox.Click += PropAction_pBoxClick;
        newPropAction_pBox.MouseHover += PropAction_pBoxMouseHover;
        newPropAction_pBox.MouseLeave += PropAction_pBoxMouseLeave;
        this.Controls.Add(newPropAction_pBox);// add to controls
        ActionPictures.Add(newPropAction_pBox); //Add to btn to list    

但是最终效果是这样的(下图)

Mouse not on pictureBox yet : http://prnt.sc/axt8b9

Mouse on the new PictureBox : http://prnt.sc/axt9ul

修改代码如下

void PropAction_pBoxMouseLeave(object sender, EventArgs e)
{
    var pictureBox = (PictureBox)sender;
    pictureBox.ImageLocation = @"PicButtons\PropertiesBtn2.png";
}

void PropAction_pBoxMouseHover(object sender, EventArgs e)
{
    var pictureBox = (PictureBox)sender;
    pictureBox.ImageLocation = @"PicButtons\PropertiesBtn2White.png";
}

对象 sender 是事件的来源。参数 sender 引用引发事件的实例。
因此事件处理程序接收到信息,什么样的对象是这个事件的来源。