I dispose a object in my code and I want to now create it again.
How can I do this?
Answer is :
private void showToolStripMenuItem_Click(object sender, EventArgs e)
{
xpPanelGroup1.CreateControl();
xpPanelGroup1.Visible = true;
...
}
private void noShowToolStripMenuItem_Click(object sender, EventArgs e)
{
xpPanelGroup1.Visible = false;
...
xpPanelGroup1.Dispose();
}
You need to create a new object after you have called
Dispose().But if you want to reuse the object later you should not dispose it, you may try to use
Hideor.Visible = falseor similar if you temporarily want to hide a control.Edit: In your code you create a new xpPanelGroup1:
but that is only local to the
showToolStripMenuItem_Clickmethod. If you just typeyou are using the class member, that is the same variable you dispose in the noShow method.
But I still recommend just hiding instead of disposing.