I want my buttons to change color on focus and then go back to the color they were when they lose focus. The buttons have different colors so I want to store the color they were before and then have it go back to that color. Here is the code I currently have:
-
class SSButton : System.Windows.Forms.Button
-
{
-
protected override void OnGotFocus(EventArgs e)
-
{
-
this.BackColor = bc;
-
BackColor = Color.FromArgb(206, 225, 253);
-
base.OnGotFocus(e);
-
}
-
protected override void OnLostFocus(EventArgs e)
-
{
-
BackColor = bc;
-
base.OnLostFocus(e);
-
}
-
public Color bc { get; set; }
-
}
-
This changes the button backcolor but when it looses focus it is changing to the backcolor of the form not to the previous backcolor. How do I get it to change to the previous backcolor and not the form backcolor?