代码如下:
传入一个窗体,先检查这个窗体是不是有副本,如果有副本,则置前,否则新创建并显示.
使用方法:
程序代码
private void OpenChild(string Frmnamespace, string ChildTypeName)
{
int ret = 0;
foreach (Form frm in MdiChildren)
{
if (frm.GetType().Name == ChildTypeName)
{
frm.Activate();
ret = 1;
break;
}
}
if (0 == ret)
{
string className = Frmnamespace + "." + ChildTypeName;
Form Instance = (Form) Assembly.Load(Frmnamespace).CreateInstance(className);
Instance.MdiParent = this;
Instance.Show();
}
}
{
int ret = 0;
foreach (Form frm in MdiChildren)
{
if (frm.GetType().Name == ChildTypeName)
{
frm.Activate();
ret = 1;
break;
}
}
if (0 == ret)
{
string className = Frmnamespace + "." + ChildTypeName;
Form Instance = (Form) Assembly.Load(Frmnamespace).CreateInstance(className);
Instance.MdiParent = this;
Instance.Show();
}
}
传入一个窗体,先检查这个窗体是不是有副本,如果有副本,则置前,否则新创建并显示.
使用方法:
程序代码
private void LbtUserManager_ItemClick(object sender, ItemClickEventArgs e)
{
OpenChild("OuterRingRoad", "frmUserManager");
}
private void MenuUserPopdemod_ItemClick(object sender, ItemClickEventArgs e)
{
OpenChild("OuterRingRoad", "frmUserPopdemod");
}
private void MenuCurrentTimeData_ItemClick(object sender, ItemClickEventArgs e)
{
OpenChild("ORRTLB", "frmNowVDIInfo");
}
private void MenuCarCheckConfig_ItemClick(object sender, ItemClickEventArgs e)
{
OpenChild("ORRTLB", "frmVDISetting");
}
{
OpenChild("OuterRingRoad", "frmUserManager");
}
private void MenuUserPopdemod_ItemClick(object sender, ItemClickEventArgs e)
{
OpenChild("OuterRingRoad", "frmUserPopdemod");
}
private void MenuCurrentTimeData_ItemClick(object sender, ItemClickEventArgs e)
{
OpenChild("ORRTLB", "frmNowVDIInfo");
}
private void MenuCarCheckConfig_ItemClick(object sender, ItemClickEventArgs e)
{
OpenChild("ORRTLB", "frmVDISetting");
}