我是C#的初学者,我想创建一个创建按钮的按钮.但这些按钮永远不会出现......
请找到我的代码:
private void addstrat3_i_Click(object sender, EventArgs e)
{
panel3strat.Width += 200;
Button addstrat3_2 = new Button();
addstrat3_2.Size = new Size(210, 41);
addstrat3_2.Location = new Point(50,50);
addstrat3_2.Visible = true;
}
Run Code Online (Sandbox Code Playgroud)
非常感谢
Fel*_*ani 10
您必须使用Controls属性在表单上添加按钮(或任何其他控件),用于示例:
private void addstrat3_i_Click(object sender, EventArgs e)
{
panel3strat.Width += 200;
Button addstrat3_2 = new Button();
addstrat3_2.Size = new Size(210, 41);
addstrat3_2.Location = new Point(50,50);
addstrat3_2.Visible = true;
// add control
this.Controls.Add(addstrat3_2);
}
Run Code Online (Sandbox Code Playgroud)