943,696 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 3184
  • VB.NET RSS
Nov 20th, 2008
0

button background colour on mouse enter event

Expand Post »
I trying to create some, what i thought, simple rollover buttons. everything works fine except that the background colour on the mouse enter is always different to what i set.

I have tried all the different flat settings on if set to 'flat' the background colour allways appears different despite to to directly set the colour - if i set the flat to 'popup' then the background colour changes fine but the borders go all funny on the mouse enter.

I just wondered if anyone had any ideas - my button code is below
cheers

VB.NET Syntax (Toggle Plain Text)
  1. Private Sub Button5_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.MouseEnter
  2. Button5.Image = My.Resources.Left
  3. Button5.FlatStyle = FlatStyle.Popup
  4. Button5.BackColor = Color.MistyRose
  5.  
  6.  
  7. End Sub
  8.  
  9. Private Sub Button5_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.MouseLeave
  10. Button5.Image = My.Resources.Left_down
  11. Button5.FlatStyle = FlatStyle.Popup
  12. Button5.BackColor = Color.MistyRose
  13.  
  14. End Sub
Reputation Points: 22
Solved Threads: 9
Junior Poster
ninjaimp is offline Offline
129 posts
since Apr 2008
Nov 21st, 2008
0

Re: button background colour on mouse enter event

I tried your code and it changes bg-color just fine. I changed FlatStyle.Flat and bg-color still changes fine.

If you set FlatStyle.Flat, have you checked FlatAppearance properties (borders & colors)? It seems FlatAppearance properties are design time props and are ReadOnly in the run-time. Anyway, changing FlatAppearance may solve your problem.
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Teme64 is offline Offline
1,024 posts
since Aug 2008
Nov 21st, 2008
0

Re: button background colour on mouse enter event

ideal - ill give it a go and let you know how i get on!

thanks
Reputation Points: 22
Solved Threads: 9
Junior Poster
ninjaimp is offline Offline
129 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Convert HTML file to PDF file through code
Next Thread in VB.NET Forum Timeline: detecting delete on row in datagridview and updating dataset





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC