【发布时间】:2016-05-01 09:54:44
【问题描述】:
我有一个表单,我在面板中添加控件
其中一个是 PictureBox 包含一个 MouseHover/MouseLeave 事件,例如 这个
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";
}
在添加按钮中我有这个代码
创建 新按钮基于 newPropAction(原始)和添加 它在一个列表中 *
" newPropAction_pBox 代表新的PictureBox & PropAction_pBox 代表原来的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
但最终效果就是这个(下图)
鼠标还没有在图片框上:http://prnt.sc/axt8b9
鼠标在新的 PictureBox 上:http://prnt.sc/axt9ul
【问题讨论】:
标签: c# mouseover mouseleave mousehover