Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello,

 

All my form are derived from a base form. Each time a form is opened, I want to add the name (or the id) of the form is a shared stack. I thought about declaring the stack in the base form. But now, how should I implement this? I need each form to add is name in the stack...How?? raising an event in the OnLoad method or just calling a method in the base form? Same onClosing. Any idea how to implement this?

 

Thank you

 

Martin

  • Leaders
Posted
Sounds like you've got a good idea for it to me. Declare it as Public Shared in the base form and use the appropriate events. Are you sure a Stack is the structure you want though? Unless they are all modal, seems like you'd run into problems trying to remove them.
--tim
Posted

Yep. As tim said.

 

The only way I see (in fact thats how we do it here in our project) is to have a FormManager Class, which internally also managers the stack, plus some events which are fired by the forms (closing, status changes, requests for additional forms to be opened), plus a defined interface which all forms must implement (through this interface the Manger controls the forms).

 

+++

 

OK, we do it with usercontrols _and_ forms, but you get the idea, hopefully.

.nerd
Posted

Yes, they are modal, that's why I thought about a stack.

I can't figure how to use event in this case (base form versus inherited form). Any example how to do it? If I raise the event in the inherited form, how the base form could catch it. Any help will be very appreciated

Thanks

  • *Experts*
Posted

Why do you need to store each form...? Can you not use the form's built-in Owner property? As long as you pass in "this" or "Me" when calling ShowDialog, the new modal window will have a reference to the opening form.

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

Because I have circular form reference.

 

Form 1 can open form 2

Form 2 can open form 3

Form 3 can open form 1 (only if form 1 isn't already open)

 

That's why I need to check if the form is opened.

 

Any idea how to implement this?

Thanks

  • *Experts*
Posted

Well if they're all being opened modally the Owner property will still work. Since you need to create a new instance of each form every time you show it, each will get its own Owner property.

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...