[英]Change pictureBox.Image with c# = FileNotFoundException
[英]Change background image of PictureBox on mouseover in C#?
当我将鼠标悬停在C#中时,如何更改PicureBox的背景图像? 我正在使用Visual C#2010 Express。 谢谢
您只需要向MouseHover Event订阅一个更改Image属性。
这应该可以解决问题:
PictureBox o = new PictureBox();
o.MouseHover += (a_sender, a_args) =>
{
PictureBox pic = a_sender as PicureBox;
pic.Image = null // New Image..
};
再次需要恢复以前的图片时使用: MouseLeave
在PictureBox属性上,双击事件MouseEnter并使用:
(sender as PictureBox).Image = Image.FromFile(// path of image1);
然后双击事件MouseLeave并使用:
(sender as PictureBox).Image = Image.FromFile(// path of image2);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.