这里以Label为例说明。
在Form1的加载加载中:
private void Form1_Load(object sender, EventArgs e)
{
Label label1=new Label()
{
Text=“欢迎来到这里!!!”,
ForeColor = System.Drawing.Color.Red,
Name=”label1”,
AutoSize=true,
Location=new System.Drawing.Point(48, 37);
};
this.Controls.Add(label1);
}
这样就将一个Label控件添加到了Form中。