Creating a rollover effect on Buttons

QMaze

New member
Joined
Sep 3, 2004
Messages
2
Programming Experience
1-3
Hello, firstly let me say Hi to all the members. First post so be nice..:p

Is it possible to be able to apply a rollover effect on a button utilizing VB.Net? I created a VB win app and want to be able to change the background of an otherwise flat button to a different color. For some reason I am under the impression I had a mouseover property in VB 6.0 but have not been programming for a few months and to get back into it, installed VS.Net to start up again. Now I have noticed by default that I already have this effect but unable to find out where the base class is doing this in order to change that rollover color. I'm assuming it is somewhere in the System.Drawing but may be incorrect.

Any help would be appreciated. Not looking for someone to do it for me if it can be done, learn more doing it myself but I have been unable to get information on this subject. Just looking for some references on how and if it can be accomplished.

Thank you Members
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
Hello and welcome.

If the FlatStyle property of a button is set to Flat, the backColor will change from it's current backColor color to a color a few shades darker when the mouse is over the button and back to it's backColor color when the mouse leaves the button. You can change the backColor to a different color than the default SystemColors.Control and see for yourself.

To change the color for mouseOvers, use the MouseEnter and MouseLeave events of the button control.
 

QMaze

New member
Joined
Sep 3, 2004
Messages
2
Programming Experience
1-3
Thank you very much. I feel so stupid. I looked for those events and for some reason did not notice them. Works like a charm.
 
Top Bottom