Reputation: 1282
According to the MSDN document, the close operation on a form shown with ShowDialog() should only cause the form to be hidden. Subsequent calls to ShowDialog() will unhide the form.
This doesn't seem to be case, exactly. I have a form with a tree view on it. The check states are preserved between calls to ShowDialog() but any node expansion the user has done is reset back to its default state. Also, the Load event is being executed every time as well. So it seems to be doing more than just "hiding" the form. Anyone have any idea what's up?
Thanks
Upvotes: 0
Views: 169
Reputation: 44275
I've experienced this issue myself. For some reason, calling Form.Hide
or setting visible = false
on a modal form will call Form.Close
in at least some cases. To work around it I set the opacity to zero. You can also use Form.Show
instead.
It is somewhat intuitive if you imagine the behavior of a modal dialogue. It blocks the parent window. So if you hide it then there would be no active window for the user to interact with. FWIW, I think the behavior should have been that the parent becomes active again. That's just not always the case.
Upvotes: 1