Question on non-modal form

D

Dom

In my program, the user can create a non-modal form (Is that the right
phrase? I mean form.Show, not form.ShowDialog). This is important,
because the user must go back and forth between the main and non-modal
window.

The user can "X" out of the non-modal form. I will know that the form
is not present by looking at form.IsDisposed. But let's say it is
Disposed. How do I get it back? Do I just do a frmNonModal f = new
FrmNonModal () again? If I can look at "IsDisposed" then I assume the
form is still present somewhere on the heap, and I don't want to get
extra copies out there.

Dom
 
I

Ignacio Machin ( .NET/ C# MVP )

In my program, the user can create a non-modal form (Is that the right
phrase?  I mean form.Show, not form.ShowDialog).

Yes

 This is important,
because the user must go back and forth between the main and non-modal
window.

The user can "X" out of the non-modal form.  I will know that the form
is not present by looking at form.IsDisposed.  But let's say it is
Disposed.  How do I get it back?

What you mean with getting it back?

 Do I just do a frmNonModal f = new
FrmNonModal () again?

Of course you can, but it will be a brand new one.

There are several ways to transfer data from one form to the other.
You can do is to keep a reference to the main form in the dialog, then
when the later is getting close you can use a public property to push
back the info.
You can make the dialog expose an event (or maybe use the Closing
event directly) and detect when it's closing and then get the data.
you can keep a reference to the dialog form in the main form and
instead of checking the IsDisposed check for IsVisible (or something
similar) and act accordinglu.
 

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