Cher
Cher

Reputation: 2947

How to properly close a form?

I close a form in C#:

loginForm.Close();

However, after that I can open it anymore, the following doesn't work:

loginForm.ShowDialog();

Why is that?

Upvotes: 0

Views: 75

Answers (1)

user585968
user585968

Reputation:

Most likely the underlying handles are disposed not to mention anything that ran in the constructor won't run again. Plus dialogs are a special beast and may have internal flags to indicate modal completion.

It's generally a bad idea to hang onto a window after it has been closed. Perhaps hiding and showing the window is more to your liking?

Upvotes: 2

Related Questions