Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将鼠标上PictureBox的背景图像更改为C#?_C#_Mouseevent_Picturebox - Fatal编程技术网

将鼠标上PictureBox的背景图像更改为C#?

将鼠标上PictureBox的背景图像更改为C#?,c#,mouseevent,picturebox,C#,Mouseevent,Picturebox,在C#中将鼠标悬停在PicureBox上时,如何更改它的背景图像? 我正在使用visual c#2010 Express。 谢谢您只需订阅鼠标悬停事件并更改图像属性即可 这应该可以做到: PictureBox o = new PictureBox(); o.MouseHover += (a_sender, a_args) => { PictureBox pic = a_sender as PicureBox; pic.Image = null // New Image..

在C#中将鼠标悬停在PicureBox上时,如何更改它的背景图像? 我正在使用visual c#2010 Express。
谢谢

您只需订阅鼠标悬停事件并更改图像属性即可

这应该可以做到:

PictureBox o = new PictureBox();
o.MouseHover += (a_sender, a_args) =>
{
    PictureBox pic = a_sender as PicureBox;
    pic.Image = null // New Image..
};

当您需要恢复以前的图片时,再次使用:
MouseLeave

您只需订阅MouseHover事件更改图像属性

这应该可以做到:

PictureBox o = new PictureBox();
o.MouseHover += (a_sender, a_args) =>
{
    PictureBox pic = a_sender as PicureBox;
    pic.Image = null // New Image..
};

当您需要恢复以前的图片时,再次使用:
MouseLeave

在PictureBox属性上,双击event MouseEnter并使用:

(sender as PictureBox).Image = Image.FromFile(// path of image1);
然后双击event Mouseleve并使用:

(sender as PictureBox).Image = Image.FromFile(// path of image2);

在PictureBox属性上,双击事件鼠标输入并使用:

(sender as PictureBox).Image = Image.FromFile(// path of image1);
然后双击event Mouseleve并使用:

(sender as PictureBox).Image = Image.FromFile(// path of image2);