【发布时间】:2019-12-18 07:44:33
【问题描述】:
我在按钮单击中创建了一个新按钮对象。现在想在被另一个按钮单击后更改按钮的颜色。
我创建了一个名为“btnBlank”的按钮对象,类似地给它一个名称为“btnBlank”,设置一个特定的位置点,给它一个大小,然后想给按钮一个颜色。但找不到方法。
private void button17_Click(object sender, EventArgs e)
{
// **** create a blank button(by btn object) ****
Button btnBlank = new Button();
btnBlank.Name = "btnBlank";
btnBlank.Location = new System.Drawing.Point(50,50);
btnBlank.Size = new System.Drawing.Size(70,30);
//Color redColor = Color.FromArgb(255, 0, 0);
btnBlank.BackColor = new System.Drawing.Color(redColor); // here's the problem
panel2.Controls.Add(btnBlank);
}
【问题讨论】: