提问者:小点点

如何通过代码在windows窗体中创建对象? [副本]


我想通过windows窗体中的代码创建标签。 我该怎么做?


共1个答案

匿名用户

您可以创建label类codebehind的实例

using System.Windows.Forms;
...

Label label = new Label();

//Now, you can assign values to the label properties

label.Text = "Welcome to Stackoverflow";

...

//Add this label to the form
this.Controls.Add(label);

MSDN文档:Label类