Link to home
Start Free TrialLog in
Avatar of Sirdots
Sirdots

asked on

changing backcolor of button to red when users move their mouse over the button

Hi,
I am using visual studio 2005 (C#). I want a situation where when users move their mouse over a button the backcolor changes to red. How can I achieve this please?


Sirdots.

Avatar of ozymandias
ozymandias
Flag of United Kingdom of Great Britain and Northern Ireland image

Is this a button on a windows form or on an asp.net webpage ?
Button button1  = new Button();
Color c = button1.BackColor;
button1.MouseEnter += new System.EventHandler(this.button1_MouseEnter);
button1.MouseLeave += new System.EventHandler(this.button1_MouseLeave);

private void button1_MouseEnter(object sender, System.EventArgs e) {
      this.button1.BackColor = Color.Red;
}

private void button1_MouseLeave(object sender, System.EventArgs e) {
      this.button1.BackColor = c;
}
Avatar of Sirdots
Sirdots

ASKER

This is a button on a windows form please
see above
ASKER CERTIFIED SOLUTION
Avatar of cybercrew
cybercrew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sirdots

ASKER

Thanks to everyone