I'm working on a project, and have two forms - One is the main form, the other a console-akin form made up of a split panel and a listbox (in panel 1)
I call a method ( writeToConsole(string textToWrite) ) which - as the name suggests - adds a line of text to the list box in the consoleWindow form
The issue I'm having is that, to show this form, I use a button that calls the show command. However, if I close said form with the "x" button in the top right corner, and then click the Show Console Button again, I get this:
ObjectDisposedException
"Cannot access a disposed object.
Object name: 'consoleOutput'."
Now, I sort of understand the issue - I had it a month or two ago, and from what I understand its because when you press the x it closes the form, meaning it has to be reinitialized / reloaded before it can be show - hence the error is ( in a very basic nutshell) "I can't show you something that doesn't exist / is in limbo"
(Again, thats the whole "Sort of on the face of it thats what it means, but really no its deeper than that" view - I understand its deeper than just that)
My question is this: Can someone please explain to me what exactly is going on / wrong, and the best way to do this sort of thing?
I understand the concept of the error, and I know a way or two to fix it, but I'm wanting to be a programmer, hence would like to know (at the very least) the flow of events for this situation and expand on my knowledge
Thanks
Just to be safe:
consoleOutput consoleOutput = new consoleOutput();
private void btnShowConsole_Click(object sender, EventArgs e)
{
//Check to see if the console is visible, of which if its not, make it so
//If it is on the other hand, just bring it to the front to show the user
if (consoleOutput.Visible == false)
consoleOutput.Show();
else
consoleOutput.BringToFront();
}