111,129
社区成员
发帖
与我相关
我的任务
分享
例子:
class lab : Label//例子
{
public Label CreateLab(string labName, int x, int y, int w, int h, string text)
{
this.Name = labName;
this.AutoSize = true;
this.Location = new System.Drawing.Point(x, y);
this.Size = new System.Drawing.Size(w, h);
this.Text = text;
return this;
}
}
private void button1_Click(object sender, EventArgs e)//调用
{
lab l = new lab();
l.CreateLab("lab", 10, 29, 20, 20, "完成");
this.Controls.Add(l);//动态添加
}
再次用的时候就不用每个属性去设置了