在Vb.net中,我在mousehover事件上更改了按钮backcolor,但在mouseleave事件中,我无法将按钮的颜色更改为标准样式。按钮看起来是全银色,缺少通常的光泽外观
在鼠标悬停事件中我给了Button1.BackColor = Color.Orange,在Mouseleave事件中我给了Button1.BackColor = Color.Silver,但是无法获得按钮的默认样式。 要做什么来恢复默认的按钮样式?
答案 0 :(得分:1)
使用 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