T
tolemaC
hi guys, I have this small example:
I have two forms, Form1 and Form2, Form1 is MainForm in my application,
The Form2 has this attribute:
public Hashtable ht;
and a TextBox too(textBox1);
in the constructor of Form2 after initialize components call, I create the
hash table and add an element:
ht = new Hashtable();
ht.Add("1", "Hello");
ok, Form2 has a method call "InitAll", is this:
public void InitAll()
{
textBox1.Text = ht["1"].ToString();
}
well, in Form1_Load I have this.
frm2 = new Form2();
frm2 is a Form1 attribute (Form2 frm2
ok, Form1 has a Button(button1), in button1_Click I have this code:
frm2.InitAll();
frm2.Show();
Form2 have MinimizeBox and MaximizeBox to false.
Ok, run application push button1 in Form1 and form2 is showed, close Form2
and push button1 other time and I get the next Exception:
"An un handled exception of type 'System.ObjectDisposedException' ocurred in
System.Windows.Forms.dll"
this ocurred when execute the "frm2.InitAll()" function in line:
textBox1.Text = ht["1"].ToString();
Well, if I open the Form2 with ShowDialog method then work fine, but if I
use Show I get this exception.
Why?
..Javier Ros Moreno.
I have two forms, Form1 and Form2, Form1 is MainForm in my application,
The Form2 has this attribute:
public Hashtable ht;
and a TextBox too(textBox1);
in the constructor of Form2 after initialize components call, I create the
hash table and add an element:
ht = new Hashtable();
ht.Add("1", "Hello");
ok, Form2 has a method call "InitAll", is this:
public void InitAll()
{
textBox1.Text = ht["1"].ToString();
}
well, in Form1_Load I have this.
frm2 = new Form2();
frm2 is a Form1 attribute (Form2 frm2
ok, Form1 has a Button(button1), in button1_Click I have this code:
frm2.InitAll();
frm2.Show();
Form2 have MinimizeBox and MaximizeBox to false.
Ok, run application push button1 in Form1 and form2 is showed, close Form2
and push button1 other time and I get the next Exception:
"An un handled exception of type 'System.ObjectDisposedException' ocurred in
System.Windows.Forms.dll"
this ocurred when execute the "frm2.InitAll()" function in line:
textBox1.Text = ht["1"].ToString();
Well, if I open the Form2 with ShowDialog method then work fine, but if I
use Show I get this exception.
Why?
..Javier Ros Moreno.