-1

Vb.net では、mousehover イベントでボタンの背景色を変更しましたが、mouseleave イベントでボタンの色を標準スタイルに変更できません。ボタンは完全な銀色に見え、通常の光沢がありません

Mousehover イベントで Button1.BackColor = Color.Orange を指定し、Mouseleave イベントで Button1.BackColor = Color.Silver を指定しましたが、ボタンのデフォルト スタイルを取得できませんでした。ボタンのスタイルをデフォルトに戻すにはどうすればよいでしょうか?

4

1 に答える 1

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
于 2013-01-27T19:23:44.087 に答える