Reputation: 31
I am looking for an possibility to Change the Button Backcolor on Button Click or on Timer.
Using MetroFramework is OK; Form Style is set to MetroForm and the Objects are usable.
I have found some code but it doesn´t work.
using MetroFramework.Forms;
using MetroFramework.Drawing;
using MetroFramework.Controls;
using System.Drawing;
private void metroButton1_Click(object sender, EventArgs e)
{
//metroButton1.BackColor = Color.Green;
metroButton1.BackColor = System.Drawing.Color.AliceBlue;
metroButton1.Text = "button click";
//metroButton1.BackColor.System.Drawing.Color.DarkGray;
Upvotes: 1
Views: 8191
Reputation: 11
Go at the bottom of button property window and set UseCustomeBackColor=true it will work
Upvotes: 0
Reputation: 31
Problem solved
usecustombackcolor set to true
metroButton1.BackColor = Color.Lime;
thx
Upvotes: 2
Reputation: 19828
According to the source code of MetroButton
class (on github), there is a property:
private bool useCustomBackColor= false;
[DefaultValue(false)]
[Category(MetroDefaults.PropertyCategory.Appearance)]
public bool UseCustomBackColor
{
get { return useCustomBackColor; }
set { useCustomBackColor = value; }
}
If this property is false in OnPaintBackground(PaintEventArgs e)
there is a code which sets default background color:
if (!useCustomBackColor)
{
backColor = MetroPaint.BackColor.Button.Normal(Theme);
}
Setting UseCustomBackColor
should solve your problem
Upvotes: 1