您可以使用 'MouseEnter' 和 'MouseLeave' 事件来更改按钮的背景图片。在 'MouseEnter' 事件中,更改按钮的背景图片为指向状态的图片,在 'MouseLeave' 事件中,更改按钮的背景图片为普通状态的图片。

以下是一个示例代码:

private void button1_MouseEnter(object sender, EventArgs e)
{
    button1.BackgroundImage = Properties.Resources.hoverImage;
}

private void button1_MouseLeave(object sender, EventArgs e)
{
    button1.BackgroundImage = Properties.Resources.normalImage;
}

请注意,您需要在项目资源中添加两个背景图片,并将它们命名为 'hoverImage' 和 'normalImage'。

WinForm 按钮鼠标悬停背景图片更改教程

原文地址: http://www.cveoy.top/t/topic/oUBl 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录