我试图用另一个表单创建一个表单实例,然后将该表单添加到主表单中。但我添加的表格没有显示。我想在所有控件顶部的中心显示该表单。
这是我的代码
BBA.Controls.ExecludeSpecialist ucExecludeSpecialist = null;
Form frmContainer = null;
private void btnExclude_Click(object sender, EventArgs e)
{
if (ucExecludeSpecialist != null)
{
if (frmContainer != null)
{
frmContainer.Controls.Remove(ucExecludeSpecialist);
ucExecludeSpecialist = null;
}
}
if (frmContainer != null)
{
this.Controls.Remove(frmContainer);
frmContainer = null;
}
frmContainer = new Form();
frmContainer.ControlBox = false;
frmContainer.StartPosition = FormStartPosition.Manual;
frmContainer.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
ucExecludeSpecialist = new BBA.Controls.ExecludeSpecialist();
ucExecludeSpecialist.SaveClicked +=
new BBA.Controls.ExecludeSpecialist.SaveComplete(OnSaveClicked);
ucExecludeSpecialist.CloseClicked +=
new BBA.Controls.ExecludeSpecialist.CloseComplete(OnCloseClicked);
ucExecludeSpecialist.BringToFront();
frmContainer.Height = ucExecludeSpecialist.Height;
frmContainer.Width = ucExecludeSpecialist.Width;
//frmContainer.Top = this.Height - frmContainer.Height / 2;
//frmContainer.Left = this.Height - frmContainer.Height / 2;
frmContainer.BringToFront();
frmContainer.TopLevel = false;
frmContainer.Controls.Add(ucExecludeSpecialist);
this.Controls.Add(frmContainer);
}
请指导我如何在中心的另一个表单的所有控件之上显示该表单。谢谢