This is my problem
TypeScript |
When I close the form and try to reopen it, this error occurs:
Can not access a disposed object.
How I solve can it?
Thanks people
TypeScript |
When I close the form and try to reopen it, this error occurs:
Can not access a disposed object.
How I solve can it?
Thanks people
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
FroglegRank #1,020 · 1.9K reputationPosted Feb 14, 2011, 7:40 PM EST
FroglegRank #1,020 · 1.9K reputationPosted Feb 14, 2011, 4:56 PM EST
{
//FormX AddNewForm = new FormX();//1* move to button event
private void button1_Click(object sender, EventArgs e)
{
FormX AddNewForm = new FormX();
AddNewForm.Show();
}
private void button2_Click(object sender, EventArgs e)
{
AddNewForm.Close();//2* or use AddNewForm.Hide()
}
}
Santiago Firezzi15 reputationPosted Feb 14, 2011, 5:03 PM EST
I edit the code:
public partial class Expedientes : UserControl { FormX AddNewForm = new FormX(); private void button1_Click(object sender, EventArgs e) { AddNewForm.button1.Click+= new EventHandler(XEvent); AddNewForm.Show(); } private void button2_Click(object sender, EventArgs e) { AddNewForm.Close(); } private void XEvent(object sender, EventArgs e) { this.textBox1.Text="Some Word"; } }FroglegRank #1,020 · 1.9K reputationPosted Feb 14, 2011, 5:12 PM EST
Can you explain why you need to click FormX.button1 from form1
Santiago Firezzi15 reputationPosted Feb 14, 2011, 5:35 PM EST
I am working with a database in this UserControl and I need a form to add data.
to that is this
Do you understand me?
FroglegRank #1,020 · 1.9K reputationPosted Feb 14, 2011, 5:47 PM EST
Santiago Firezzi15 reputationPosted Feb 14, 2011, 5:55 PM EST
There is only 1 TextBox are like 15 ...
FroglegRank #1,020 · 1.9K reputationPosted Feb 14, 2011, 6:01 PM EST
user control and Xform are already open ?
You want Xform textbox.text to be entered into database by clicking button on formX
Santiago Firezzi15 reputationPosted Feb 14, 2011, 6:13 PM EST
The UserControl have the datagrid with a DataSet and another things.
I use the XForm to insert a new row in the UserControl.
The data comes from the text boxes in the XForm
FroglegRank #1,020 · 1.9K reputationPosted Feb 14, 2011, 6:30 PM EST
Santiago Firezzi15 reputationPosted Feb 14, 2011, 6:42 PM EST
In a moments I upload a project with my problem
Santiago Firezzi15 reputationPosted Feb 14, 2011, 6:59 PM EST
FroglegRank #1,020 · 1.9K reputationPosted Feb 14, 2011, 7:23 PM EST
Form2 agregardatos closes and then cannot be used again ?
change
agregardatos.Close();
to
agregardatos.Hide();
Santiago Firezzi15 reputationPosted Feb 14, 2011, 7:29 PM EST
Modify the code
And look what happens when you add 2 or more rows...
I can repair the problem, so it's done
Thanks a lot for your assistance
Grettings