将鼠标上PictureBox的背景图像更改为C#?
在C#中将鼠标悬停在PicureBox上时,如何更改它的背景图像? 我正在使用visual c#2010 Express。将鼠标上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..
谢谢您只需订阅鼠标悬停事件并更改图像属性即可 这应该可以做到:
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);