创建一个按钮,创建按钮
问题描述:
我是C#中的一个begginer,我想创建一个创建按钮的按钮。 但这些按钮不会出现...创建一个按钮,创建按钮
请找我的代码:
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;
}
非常感谢
答
您可以选择使用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);
}
答
您需要将按钮添加到窗体。
this.Controls.Add(addstrat3_2);
看起来像你只是打败了我! – 2013-04-29 14:55:32
非常感谢; * – 2013-04-29 15:12:45