1

I have two buttons in my activity, clicking any of the two of them should unhighlight the other one. The result on my work is both of them are highlighted.

private void button3_Click(object sender, EventArgs e)
{
    button3.BackColor = Color.Green;
}

private void button4_Click(object sender, EventArgs e)
{
    button4.BackColor = Color.Red;
}
AbdelAziz AbdelLatef
  • 3,650
  • 6
  • 24
  • 52
  • Based on that code, I'd expect it to work just like you described. What did you try to do to get the results you want? – Jonesopolis Oct 14 '20 at 19:35
  • The result that I want mate is, if im going to click the button 3 it should be highlighted and if im going to click the button 4 it should be highlighted this will trigger that if im going to click the button 4 the highlighted button 3 should not be highlighted. – JohnSanity COPH Oct 14 '20 at 19:39
  • Ive done some solutions but it wont work – JohnSanity COPH Oct 14 '20 at 19:40

1 Answers1

1

You need to reset the other button to its default BackColor like this

private void button3_Click(object sender, EventArgs e)
{
    button3.BackColor = Color.Green;
    button4.BackColor = default(Color);
}

private void button4_Click(object sender, EventArgs e)
{
    button4.BackColor = Color.Red;
    button3.BackColor = default(Color);
}
AbdelAziz AbdelLatef
  • 3,650
  • 6
  • 24
  • 52