无法访问已释放的对象!!!!!
以下是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
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
...全文
相关推荐
C++对象的动态建立与释放详解
我们知道可以用new运算符可以动态的分配内存,用delete运算符可以释放这些内存。当我们使用new运算符动态的分配一个内存之后,会自动返回一个该内存段的起始地址,也就是指针。
c++中单例模式对象的释放控制
c++中单例模式对象的释放控制,txt文件格式的,哈哈哈
ccie 最新考试大纲!!!!!
ccie 最新考试大纲!!!!!ccie 最新考试大纲!!!!!ccie 最新考试大纲!!!!!ccie 最新考试大纲!!!!!
北航3D!!!!!地图
北航3D!!!!!地图北航3D!!!!!地图北航3D!!!!!地图
C#实现关闭子窗口而不释放子窗口对象的方法
下面小编就为大家带来一篇C#实现关闭子窗口而不释放子窗口对象的方法 。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧


.NET Framework
