C# WinForm:无法访问已释放的对象
2021-07-03 01:39
标签:ima 等于 || exp content 处理 cli alt detail C# WinForm:无法访问已释放的对象 标签:ima 等于 || exp content 处理 cli alt detail 原文地址:https://www.cnblogs.com/asdyzh/p/9902520.html
private void OpenChildFrmToolStripMenuItem_Click(object sender, EventArgs e)
{
myChildFrm = new ChildFrm();//创建子窗口对象
myChildFrm.Show();//显示子窗口
myChildFrm.Focus();//使子窗口获得焦点
}
{
if(myChildFrm != null)
{
myChildFrm.Show();//显示子窗口
myChildFrm.Focus();//使子窗口获得焦点
}
else
{
myChildFrm = new ChildFrm();//创建子窗口对象
myChildFrm.Show();//显示子窗口
myChildFrm.Focus();//使子窗口获得焦点
}
}
{
if(myChildFrm != null)
{
if(myChildFrm.IsDisposed)
myChildFrm = new ChildFrm();//如果已经销毁,则重新创建子窗口对象
myChildFrm.Show();
myChildFrm.Focus();
}
else
{
myChildFrm = new ChildFrm();
myChildFrm.Show();
myChildFrm.Focus();
}
}
{
if(myChildFrm == null || myChildFrm.IsDisposed)
{
myChildFrm = new ChildFrm();
}
myChild..MdiParent = this; //建立父子关系
myChildFrm.Focus(); //子窗口获得焦点
}