0

I have this six buttonenter image description here

After i press one button, for example i press settings it will open an new windows after i close that windows the button remain pressed. enter image description here

Here are the settings button code:

  Private Sub btn_SETTINGS_MouseEnter(sender As System.Object, e As System.EventArgs) Handles btn_SETTINGS.MouseEnter
    btn_SETTINGS.ForeColor = Color.White

End Sub

Private Sub btn_SETTINGS_MouseLeave(sender As System.Object, e As System.EventArgs) Handles btn_SETTINGS.MouseLeave
    btn_SETTINGS.ForeColor = SystemColors.HotTrack




End Sub
Private Sub btn_SETTINGS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_SETTINGS.Click
    OpenSettings()
End Sub

Any suggestion what can i do to fix this problem.

Sayse
  • 42,633
  • 14
  • 77
  • 146
user3223293
  • 83
  • 2
  • 11
  • Maybe your button has simple the focus (I assume you are talking about a WinForms application)? – Thomas Krojer Aug 26 '15 at 06:56
  • i forgot to mention my application is winForms app, and after my mouse will i want the button to be unpressed – user3223293 Aug 26 '15 at 07:01
  • One of the answers here http://stackoverflow.com/questions/148729/how-to-set-change-remove-focus-style-on-a-button-in-c show you how to "unpress" your button. As I told you, your button is not pressed. You are using the "flat" style, and the button with the focus is drawn with a different border size. But read this other answer for more details. – Thomas Krojer Aug 26 '15 at 07:35

1 Answers1

1

Okay, this problem seems related to Focus that got set to the button when you pressed it. Very easy and quick fix of this problem is, change the focus of control to some other control. On the same side, add one label control which is of Hidden type say lblHidden. So when you're doing following code then change focus.

Private Sub btn_SETTINGS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_SETTINGS.Click
    OpenSettings()
    Me.ActiveControl = lblHidden 
End Sub

This will change the focus to hidden control. However if you are doing any formatting change of button on click event then revert it back to original in above even.t

Yog
  • 112
  • 12
Amnesh Goel
  • 2,617
  • 3
  • 28
  • 47