Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how i do make the button to change its color to red from green and from green to red when is clicked
Posted

1 solution

Assuming that button1 is your button

1. Add
button1.Click +=new EventHandler(button1_Click);
after InitializeComponent();

2. Add the method button1_Click:
C#
private void button1_Click(object sender, EventArgs e)
        {
           if(button1.BackColor == Color.Red)button1.BackColor = Color.Green;
           else button1.BackColor = Color.Red;
        }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900