![](/img/trans.png)
[英]How to change color of very button in button arrays when i hover mouse to it in c# winform
[英]How to create effect: light button when mouse over button in 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;
在按钮的Mouse_Enter事件上,更改按钮的背景图像,然后将其更改回Mouse_Leave。
private Image cachedImage = Image.FromFile(@"C:\mouseOver.jpg");
...
button1.BackgroundImage = cachedImage;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.