Boni,
| 1. what is the idea behind the dependency of destruction from the method,
| how the form shown?
Form.Show (inherited from Control.Show) shows the form modelessly. The code
that displays the form will continue running while the form is being
displayed.
Form.ShowDialog shows the form as a modal dialog box. The code that displays
the form will wait until the form is closed.
Seeing as its common to set some values, ShowDialog, retrieve some values,
ShowDialog does not do a Dispose so as to allow you to retrieve values of
controls, when you are done retrieving values of controls, you need to call
Dispose.
Because of the indeterminate time when a modeless form is closed, other then
the Close event there is no real chance to call Dispose on the form...
| 2. what is the good practice of taking data from the form. Should this be
| done in OnFinish button handler?
I normally use Form.ShowDialog, then take any data from the form, then call
Form.Dispose.
For MDI children & other modeless forms, there is some command object
(button, menu, toolbar, etc...) that causes the information to be saved or
the information is implicitly saved by virtue of being bound to a
datasource.
Hope this helps
Jay
| Dear Herfried,
| 1. what is the idea behind the dependency of destruction from the method,
| how the form shown?
| 2. what is the good practice of taking data from the form. Should this be
| done in OnFinish button handler?
|
Newsbeitrag
| | >> if I do myform.close() is it disposed or not?
| >> is it correct do following?
| >> myForm.close()
| >> Info=SomeControlOntheForm.text
| >> This seems to work. But am not sure that it is waterproof.
| >
| > It depends on how you show your form. When showing it by calling its
| > 'Show' method and closing it using its 'Close' method, the form will be
| > disposed. However, if you show your form using 'ShowDialog', it won't be
| > disposed automatically when it gets closed.
| >
| > --
| > M S Herfried K. Wagner
| > M V P <URL:
http://dotnet.mvps.org/>
| > V B <URL:
http://classicvb.org/petition/>
|
|