dubem1 Posted March 21, 2003 Posted March 21, 2003 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 Quote
Leaders quwiltw Posted March 21, 2003 Leaders Posted March 21, 2003 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. Quote --tim
Heiko Posted March 21, 2003 Posted March 21, 2003 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. Quote .nerd
dubem1 Posted March 21, 2003 Author Posted March 21, 2003 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 Quote
*Experts* Nerseus Posted March 22, 2003 *Experts* Posted March 22, 2003 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 Quote "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
dubem1 Posted March 24, 2003 Author Posted March 24, 2003 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 Quote
*Experts* Nerseus Posted March 24, 2003 *Experts* Posted March 24, 2003 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 Quote "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
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.