我有一个父窗体 form ,他有两个子窗体,child1,child2. 点击form上的菜单menu1出现child1,点击menu2出现child2。切换没问题,关键是当关闭子窗体后,再去点击菜单打开的时候会出现错误代码是:
private void form_main_Load(object sender, System.EventArgs e)
{
//初始化窗口1
child1.MdiParent = this;
child1.FormBorderStyle = FormBorderStyle.FixedDialog;
child1.WindowState = System.Windows.Forms.FormWindowState.Maximized;
child1.Show();
////初始化窗口2
child2.MdiParent = this;
child2.FormBorderStyle = FormBorderStyle.FixedDialog;
child2.WindowState = System.Windows.Forms.FormWindowState.Maximized;
child2.Show();
}private void menu1_Click(object sender, System.EventArgs e)
{
child1.Visible = true;
child1.Show(); //这句有没有都会出现
child1.Activate();
}
具体信息是:
未处理的“System.ObjectDisposedException”类型的异常出现在 system.windows.forms.dll 中。
其他信息: 无法访问名为“Form1”的已处置对象。请问,如何判断窗体是否关闭了?
private void form_main_Load(object sender, System.EventArgs e)
{
//初始化窗口1
child1.MdiParent = this;
child1.FormBorderStyle = FormBorderStyle.FixedDialog;
child1.WindowState = System.Windows.Forms.FormWindowState.Maximized;
child1.Show();
////初始化窗口2
child2.MdiParent = this;
child2.FormBorderStyle = FormBorderStyle.FixedDialog;
child2.WindowState = System.Windows.Forms.FormWindowState.Maximized;
child2.Show();
}private void menu1_Click(object sender, System.EventArgs e)
{
child1.Visible = true;
child1.Show(); //这句有没有都会出现
child1.Activate();
}
具体信息是:
未处理的“System.ObjectDisposedException”类型的异常出现在 system.windows.forms.dll 中。
其他信息: 无法访问名为“Form1”的已处置对象。请问,如何判断窗体是否关闭了?
解决方案 »
- Listview已经设置为两列,怎样通过代码一次性添加一行数据,包括了每列的数据
- WPF 控件显示
- 玩过xbap进来看看,这个是什么情况啊
- c# 托盘问题! 可以显示托盘,鼠标停留也能显示托盘文本,就是不响应鼠标的各种事件!
- asp.net的问题
- 在Main()方法中使用try{……}catch为什么捕捉不到异常?
- 如何通过JS访问另一网页中的JS函数?
- 高分求问:Request.Querystring为什么中文值传下来变成了问号 ?
- 写了一个C#代码生成器~
- 在comboBox控件中怎样引用xml文件的节点
- 请教各位,如果通过任务栏还原窗口时如何使窗口中的某个控件获取焦点???
- 如何得到TextBox中光标的屏幕坐标??(winform)
{
}private void menu1_Click(object sender, System.EventArgs e)
{ //初始化窗口1
child1.MdiParent = this;
child1.FormBorderStyle = FormBorderStyle.FixedDialog;
child1.WindowState = System.Windows.Forms.FormWindowState.Maximized;
child1.Show();
////初始化窗口2
child2.MdiParent = this;
child2.FormBorderStyle = FormBorderStyle.FixedDialog;
child2.WindowState = System.Windows.Forms.FormWindowState.Maximized;
child2.Show(); child1.Visible = true;
child1.Show(); //这句有没有都会出现
child1.Activate();
}