G
Guest
Hello everybody,
The MSDN says about ShowDialog that
"When a form is displayed as a modal dialog box, clicking the Close button
(the button with an X at the upper-right corner of the form) causes the form
to be hidden and the DialogResult property to be set to DialogResult.Cancel.
Unlike modeless forms, the Close method is not called by the .NET Framework
when the user clicks the close form button of a dialog box or sets the value
of the DialogResult property. Instead the form is hidden and can be shown
again without creating a new instance of the dialog box. Because a form
displayed as a dialog box is not closed, you must call the Dispose method of
the form when the form is no longer needed by your application."
The way I understand this is that even if I re-instantiate the class that
implements my form, the framework will reuse some previously created
structures and that's how I would explain why the Load event is not fired for
subsequent calls to ShowDialog.
So here is my question: What is the pattern I need to use to display one
form over and over and make sure that all internal controls are initialized
to proper values every time the form is shown? What is the event that's fired
every time ShowDialog is called, if there is such an event? If not, how else
should I approach this?
TIA,
Eddie
The MSDN says about ShowDialog that
"When a form is displayed as a modal dialog box, clicking the Close button
(the button with an X at the upper-right corner of the form) causes the form
to be hidden and the DialogResult property to be set to DialogResult.Cancel.
Unlike modeless forms, the Close method is not called by the .NET Framework
when the user clicks the close form button of a dialog box or sets the value
of the DialogResult property. Instead the form is hidden and can be shown
again without creating a new instance of the dialog box. Because a form
displayed as a dialog box is not closed, you must call the Dispose method of
the form when the form is no longer needed by your application."
The way I understand this is that even if I re-instantiate the class that
implements my form, the framework will reuse some previously created
structures and that's how I would explain why the Load event is not fired for
subsequent calls to ShowDialog.
So here is my question: What is the pattern I need to use to display one
form over and over and make sure that all internal controls are initialized
to proper values every time the form is shown? What is the event that's fired
every time ShowDialog is called, if there is such an event? If not, how else
should I approach this?
TIA,
Eddie