Hi
I have a button of type SfButton, called AutoButton, and I want it to go green when the legend is "AUTO ON".
Here is my code:
private void AutoButton_MouseClick(object sender, MouseEventArgs e)
{
if (AutoButton.Text == "AUTO OFF")
{
var confirmResult = MessageBox.Show("Auto Mode selected",
"Please confirm",
MessageBoxButtons.YesNo);
if (confirmResult == DialogResult.Yes)
{
AutoButton.Text = "AUTO ON";
AutoButton.BackColor = Color.Green;
}
}
else
{
AutoButton.Text = "AUTO OFF";
AutoButton.BackColor = Color.Silver;
}
AutoButton.Refresh();
}
The text changes to "AUTO ON", but the button does not go green.
If I use a standard button, it works. Here is the code for that:
private void button1_MouseClick(object sender, MouseEventArgs e)
{
if (button1.Text == "AUTO OFF")
{
var confirmResult = MessageBox.Show("Auto Mode selected",
"Please confirm",
MessageBoxButtons.YesNo);
if (confirmResult == DialogResult.Yes)
{
button1.Text = "AUTO ON";
button1.BackColor = Color.Green;
}
}
else
{
button1.Text = "AUTO OFF";
button1.BackColor = Color.Silver;
}
button1.Refresh();
}
.... why isn't the SfButton changing colour?
Any help would be gratefully received.
Thank you.