Showing a nonmodal form only once

  • Thread starter Thread starter Edgardo Rossetto
  • Start date Start date
E

Edgardo Rossetto

Hi, I'm having this little issue which i dont know how to fix properly.

I have a button that instanciates a form, then it shows it normally (not
modal), this opened form is owned by the main form, the problem is that
I dont know how to check if it was previously openeded (the owned form).

So i made a private bool field in the main form indicating weather the
owned form is opened or not, so far thats good.

My question is if my owned form is implicitly aware of the instance of
the owner form, that is, if I can change public/protected properties
from the owned form, of if I need to pass by ref the instance of the
owner to the owned form constructor.

You see, I dont want to create unnecessary references if possible.

Thanks,
Edgardo
 
You could keep a reference to the instance of the new form, so the next time
the user presses the button you just call Var.Show(); To know when the new
form is closed, create a method in the owner form and assign it to the new
forms Close Event.

--
Thanks
Wayne Sepega
Jacksonville, Fl


"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein
 
Instead of creating the form everytime, you could create it only once and
then wherever the user closes it, just hide the form but don't close it.
When its requested again, show it to the user.
 
You could use the singleton patten to accomplish this. In doing so you can
treat the form as if it was a normal form.

Google Singleton Pattern C# or VB.Net

Best of luck
Nick
 
Back
Top