在 C# 中的鼠标悬停时更改 PictureBox 的背景图像?

crm*_*ham 1 c# picturebox mouseevent

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

Kam*_*ach 5

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

这应该可以解决问题:

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

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