无法访问已释放的对象!!!!!
以下是form1的代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace _20080517S2
{
public partial class MainForm : Form
{
From2 fa;
public MainForm()
{
InitializeComponent();
fa = new From2();
fa.MdiParent = this;
fa.WindowState = FormWindowState.Maximized;
fa.button1.Click += new EventHandler(button1_Click);
}
void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(fa.Timu);
fa.Close();
}
private void 增加题目ToolStripMenuItem_Click(object sender, EventArgs e)
{
fa.Show();
}
}
}
下面是form2的代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace _20080517S2
{
public partial class From2: Form
{
public From2()
{
InitializeComponent();
}
public string Timu
{
get { return this.textBox1.Text; }
}
public string XX1
{
get { return this.textBox2.Text; }
}
public string XX2 {
get { return this.textBox3.Text; }
}
public string XX3 {
get { return this.textBox4.Text; }
}
public string XX4 {
get { return this.textBox5.Text; }
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(this.Timu);
}
}
}
第一次点击”增加题目“时 form2 正常SHOW出来!
输入完后 点FORM2的Button1关闭
然后第二次点击“增加题目”的时候就会出现 “无法访问已释放的对象” 的错误
为什么会这样
环境:VS2008