c# - 如何创建效果:鼠标悬停在 C# Winform 中的按钮上时按钮亮起
解决方案
您可以使用两个图像。一张用于普通按钮,一张用于悬停按钮状态。从工具箱中拖动按钮控件,将FlatStyle设置为Popup。
创建button.MouseEnter和button.MouseLeave事件。
// Let's say you have images stores in resource file..
private static readonly Image image1 = Resources.button1;
private static readonly Image image2 = Resources.button2;
...
button1.MouseEnter += (s,e) => button1.Image = image2;
// And revert back
button1.MouseLeave += (s,e) => button1.Image = image1;
推荐阅读
- javascript - 渲染对象数组 React
- javascript - React animate fade-in and fade-out with CSSTransitionGroup on conditionally rendered component
- javascript - Radio - 选中时在 div 中添加类
- java - How can I save and get a image from my database
- python - 将扫描路径绘制到图像上
- java - Throwable 类曾经是抽象的吗?
- javascript - 使用 JQuery .load() 函数后 Javascript 不起作用
- makefile - Makefile 不会使用 touch 创建多个 txt 文件
- python - 如果在同一个 HTML 树下有多个,我将如何抓取一些“标题”属性?
- javascript - 使空的 innerhtml 元素的显示隐藏工作