How can I change the background image of a PicureBox when I hover my mouse over it in C#? I'm using visual c# 2010 Express. Thanks
当我将鼠标悬停在C#上时,如何更改PicureBox的背景图像?我正在使用visual c#2010 Express。谢谢
2 个解决方案
#1
4
You just need to subscribe to MouseHover Event an change Image Property.
您只需要订阅MouseHover事件即可更改图像属性。
This should do the trick:
这应该是诀窍:
PictureBox o = new PictureBox();
o.MouseHover += (a_sender, a_args) =>
{
PictureBox pic = a_sender as PicureBox;
pic.Image = null // New Image..
};
Again when you need to restore previous picture use: MouseLeave
再次当您需要恢复上一张图片时:MouseLeave
#2
0
On PictureBox properties, double click on event MouseEnter and use:
在PictureBox属性上,双击事件MouseEnter并使用:
(sender as PictureBox).Image = Image.FromFile(// path of image1);
then double click on event MouseLeave and use:
然后双击事件MouseLeave并使用:
(sender as PictureBox).Image = Image.FromFile(// path of image2);
#1
4
You just need to subscribe to MouseHover Event an change Image Property.
您只需要订阅MouseHover事件即可更改图像属性。
This should do the trick:
这应该是诀窍:
PictureBox o = new PictureBox();
o.MouseHover += (a_sender, a_args) =>
{
PictureBox pic = a_sender as PicureBox;
pic.Image = null // New Image..
};
Again when you need to restore previous picture use: MouseLeave
再次当您需要恢复上一张图片时:MouseLeave
#2
0
On PictureBox properties, double click on event MouseEnter and use:
在PictureBox属性上,双击事件MouseEnter并使用:
(sender as PictureBox).Image = Image.FromFile(// path of image1);
then double click on event MouseLeave and use:
然后双击事件MouseLeave并使用:
(sender as PictureBox).Image = Image.FromFile(// path of image2);