Problem with showDialog

Y

Yash

Hi,

I am trying to create a sort of a wizard, that has 3
different screens in succession. The first screen is a
Form, with a Next button. In the onClick handler for this
button, I have closed the Form, set its visible property
to False and opened the next form:
Me.Close()
Me.Visible = False
m_NextForm.ShowDialog()


The next Form opens when I click on the Next button and
the first form disappears.

The second Form has a Back button which when cliked,
should show the first form and close the second form:
Me.Close()
Me.Visible = False
m_PrevForm.ShowDialog()

However, when I click the button, the following exception
is thrown:
An unhandled exception of
type 'System.InvalidOperationException' occurred in
system.windows.forms.dll

Additional information: Forms that are already displayed
modally cannot be displayed as a modal dialog. Close the
form before calling showDialog.


My question is, why does it ask for the Form to be closed
first, even though it has already been closed?
Can someone suggest a solution?

Thanks
Yash
 
C

Charles de Pardieu

Hi !

I think the best way is to have only one Form, with three Panels of the same
size, at the same place. You hide two of them and work with the one shown.

Hope that helps.
 

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

Top