Question-C#窗体中代码添加控件

Posted on 2019-12-31 21:11  冰糖Luck1996  阅读(705)  评论(0编辑  收藏  举报

 

1             Label SnLable = new Label
2             {
3                 Size = new Size(SnLength, SnLength),
4                 BackColor = Color.Red,
5                 Location = new Point(10, 10),
6                 BorderStyle = BorderStyle.FixedSingle
7             };
8 
9             this.Controls.Add(SnLable);

 

写完之后不要忘记this.Controls.Add(SnLable);