在 Vb.net 中,我在 mousehover 事件上更改了按钮背景色,但在 mouseleave 事件上,我无法将按钮的颜色更改为标准样式。Button 看起来是全银色,缺少通常的光泽外观
在 Mousehover 事件上我给了 Button1.BackColor = Color.Orange 和在 Mouseleave 事件上我给了 Button1.BackColor = Color.Silver ,但无法获得按钮的默认样式。怎样做才能恢复按钮的默认样式?
使用Button1.MouseEnter不会改变按钮颜色,直到鼠标稳定在按钮上,而使用Button1.MouseHover将在颜色鼠标悬停在按钮上时改变按钮颜色。
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'AddHandler Button1.MouseEnter, AddressOf btn1MouseHover
AddHandler Button1.MouseHover, AddressOf btn1MouseHover
AddHandler Button1.MouseLeave, AddressOf btn1MouseLeave
End Sub
Private Sub btn1MouseLeave(ByVal sender As Object, ByVal e As EventArgs)
Button1.UseVisualStyleBackColor = True
End Sub
Private Sub btn1MouseHover(ByVal sender As Object, ByVal e As EventArgs)
Button1.BackColor = Color.Red
End Sub