problem recreating disposed form

  • Thread starter Thread starter Houston Keach
  • Start date Start date
H

Houston Keach

The following function creates an instance of my login form, displays
it using ShowDialog() and then calls Dispose() to free the resources.

private void Login()
{
FormLogin LoginForm = new FormLogin();
LoginForm.ShowDialog();
LoginForm.Dispose();
}

If the function is called a second time I get an exception,
System.ObjectDisposedException, when one of the TextBox controls on
the form is accessed. It seems like all of the controls should have
been initialized just like the first time. What am I missing?

--Houston Keach
 
The barebone code that does what you do works fine. How to you access the
textbox control? Do you have by any chance an InputPanel reference in the
TextBox.Focus event or something like that?
 
Yes, it's crashing in the EnabledChanged event handler of the
InputPanel when it tries to relocate the TextBox.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top