在 visual basic 中通过在运行时单击另一个按钮来更改按钮颜色?

Changing button color by clicking another button during runtime in visual basic?

我在单击按钮时创建了一个新的按钮对象。现在想在被另一个按钮点击后改变按钮的颜色。

我创建了一个名为 "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);
        }

A struct Color 已经将一些预定义颜色初始化为静态成员。 简单地做:

btnBlank.BackColor = Color.Red

更多info about Color.