Form Navigation Via Show() or ShowDialog()

G

Ginno

Hi All,

My application:

Pocket PC 2002
Has a number of forms, all of which are loaded once during application
start up and managed (shown / hidden) from a central class
Each form saves its data as it is 'closed' (Determines if changes
made, if so save data to DB)
Forms can be navigated to in the following ways
Clicking on a toolbar which is always present
OR
From the current form the user can open a specific form, input data
and return to the inital form to continue entering data

My problem is around the use of Show() or ShowDialog() when it comes
to displaying the forms

If I use ShowDialog()

- ADVANTAGES
** Closing() event is called as dialog is closed by user hitting 'ok'
allowing data to be saved
** If the user hits 'ok' the dialog is hidden, not disposed, meaning
the same dialog / form object can be used/opened again
** The ShowDialog() method allows for pauses in the code so I can
guarantee that the user has completed the information in the 'child'
dialog before moving on to run code in the 'parent' dialog for cases
where a 'parent' form is opening a 'child' dialog form. (so not cases
of form opening thru the toolbar)

- DISADVANTAGES
** If the Dialog is to be closed/hidden because the user has selected
another form from the toolbar then the toolbar manager needs to call
OpenForm.Close() to fire the closing event to save the data and allow
focus to be moved to the new dialog open
** Calling OpenForm.Close() completely destroys the OpenForm object
meaning if it is attempted to be opened again I get an
'ObjectDisposed' exception


If I use Show()

- ADVANTAGES
** I can hide and show the forms via the toolbar manager
OpenForm.Hide() with no problems

- DISADVANTAGES
** The closing() event is not called so all data saving has to be done
through Deactivate() which is very unreliable as deactivate will be
called in unexpected cases (eg. as active sync dialog appears) meaning
data will be saved before it is complete
** Don't have the luxury of the pause in the code, so i have to pass
messages back to the 'parent' form so i knows the user has completed
the entering of information

I don't care if I use Show or ShowDialog but the problem is both of
methods have disadvantages that I currently cannot overcome.

I was just wondering anyone had an application that acted in a similar
manner and managed to find a solution to either method of showing
dialogs. If so could you please enlighten me as to the best
navigation between forms solution.

Thanks in advance

ginno...
 
B

BuddahDog

Hi Ginno -

To get the "best of both worlds" -
Use the Show method, but on each form set MinimizeBox = False.
This will replace the "X" with an "OK" on the form and allow the
Closing event to fire. That way you don't have to depend on the
Deactivate event.

-Dog
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top