我现在有母亲表格,我想以编程方式创建一个新表格。我创建了新表单,但无法向表单添加控件。
private void CreateWindows()
{
newWindow = new Form();
Application.Run(newWindow);
newWindow.Activate();
newWindow.Size = new System.Drawing.Size(40, 40);
Label label1 = new Label();
newWindow.Controls.Add(label1);
label1.Text = "HI";
label1.Visible = true;
label1.Size = new System.Drawing.Size(24, 24);
label1.Location = new System.Drawing.Point(24, 24);
}
我已经尝试了上面的代码,显示了新表单,但我看不到 label1。
我很感激任何帮助。