Differences between Show and Showdialog of the Form Class

There are couple of situations at which you need to decide on using the Show() and ShowDialog() methods of the Form's class.

Modal Dialogs (ShowDialog's) dont get disposed automatically on close as their counterparts.

 The ShowDialog method of the form class functions differently than the Show method.

 1) It returns a value which can be used to determine how the user closed the form (using the DialogResult property)

 2) It does not call the Dispose method automatically on its close. But, Show (modeless) does dispose on close.

 One of the benefits of the modal dialog not being dispose after its closed is that the data can be retreived from the modal form.

 But a good practice, would be to call the Dispose method in the finally block , when using the ShowDialog method, so that the resources and handles are released from memory

By [)ia6l0 iii   Popularity  (2221 Views)