我从一个dll创建一个主项目表单的实例,当第一次重新启动方法时一切正常,但是当我第二次调用该方法时,它再次显示第一个创建的值。还有一个datagridview使用相同的逻辑,但没有创建运行时,它工作正常。我也试图不创建那些标签运行时但它没有什么区别。
DLL
using (frmBlaBla FRMBLABLAMM = new frmBlaBla())
{
Label lbl1 = new Label();
lbl1.Name = "lbl1";
lbl1.Font = new System.Drawing.Font("Tahoma", 15, System.Drawing.FontStyle.Regular);
lbl1.Location = new System.Drawing.Point(345, 15);
lbl1.Text = "LABEL 1";
lbl1.Size = new System.Drawing.Size(200, 30);
lbl1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
FRMBLABLAMM.SomePanel.Controls.Add(lbl1);
Label lbl2 = new Label();
lbl2.Name = "lbl2";
lbl2.Font = new System.Drawing.Font("Tahoma", 20, System.Drawing.FontStyle.Regular);
lbl2.Location = new System.Drawing.Point(340, 45);
lbl2.Size = new System.Drawing.Size(200, 45);
lbl2.TextAlign = System.Drawing.ContentAlignment.TopCenter;
lbl2.Text = SomeMethodReturnsString(Param);
FRMBLABLAMM.SomePanel.Controls.Add(lbl2);
FRMBLABLAMM.ShowDialog();
}
frmMaster
frmBlaBla FRMBLABLA;