Reputation: 11325
private void button13_Click(object sender, EventArgs e)
{
button13.ForeColor = Color.Red;
debugMode = true;
}
I want following set once I click the button:
button13.ForeColor = Color.Red;
debugMode = true;
And next time I will click the button so the button will be back to Color.Black
and debugMode
will be false
.
And if its on the other switch, if the button Color.Black
and debugMode
is false
and I click the button the values change Color.Red
and debugMode
is true
.
I already have a bool variable for using
debugButtonSwitch
Upvotes: 0
Views: 2040
Reputation: 3138
private void button13_Click(object sender, EventArgs e)
{
button13.ForeColor = (debugMode) ? Color.Black : Color.Red;
debugMode = !debugMode;
}
And if you want to change the button status from another event you can put this code inside the separate method and call it anywhere that you need
Upvotes: 2
Reputation: 49988
Why not just use debugMode
like this:
private void button13_Click(object sender, EventArgs e)
{
button13.ForeColor = (debugMode) ? Color.Black : Color.Red;
debugMode = !debugMode;
}
Upvotes: 6