当我在 C# 中将鼠标悬停在 PicureBox 上时,如何更改它的背景图像?我正在使用 Visual c# 2010 Express。谢谢
问问题
5358 次
2 回答
5
您只需要订阅 MouseHover 事件更改图像属性。
这应该可以解决问题:
PictureBox o = new PictureBox();
o.MouseHover += (a_sender, a_args) =>
{
PictureBox pic = a_sender as PicureBox;
pic.Image = null // New Image..
};
当您需要恢复以前的图片时再次使用:MouseLeave
于 2012-05-05T14:08:13.327 回答
1
在 PictureBox 属性上,双击事件 MouseEnter 并使用:
(sender as PictureBox).Image = Image.FromFile(// path of image1);
然后双击事件 MouseLeave 并使用:
(sender as PictureBox).Image = Image.FromFile(// path of image2);
于 2016-08-17T18:32:08.340 回答