Reputation: 1268
How would I make two buttons appear the same when one is hovered over?
Picture of the buttons I want to be shown are here:
https://i.sstatic.net/b4P6B.png
How would I make the button with the green image in the center appear as the same style (colors, borders, etc...) when the Sign On
one has been hovered over / clicked?
I'm using Windows Forms.
Upvotes: 0
Views: 1802
Reputation: 31454
Simply add handler for MouseEnter event on your "sign on" button - all you have to do in this very handler then, is changing second button's styles (implementing MouseLeave might be useful too - to revert second button to it's original style).
Code sample:
this.ButtonSignOn.MouseEnter += this.ChangeOtherButton;
this.ButtonSingOn.MouseLeave += this.RevertOtherButtonChanges;
// later on
private void ChangeOtherButton(object sender, EventArgs e)
{
this.OtherButton.ForeColor = Colors.Red;
this.OtherButton.BackColor = Color.Blue;
// more styling ...
}
// mostly same stuff when reverting changes
You could refactor those 2 handlers into one, and simply passing colors, fonts and other styles as you go... but this should be enough anyways.
Upvotes: 0
Reputation: 7342
This can be done using event handlers on mouse over/out, but frankly the right choice is to make a usercontrol containing both buttons and use that instead of the two...
Upvotes: 1