larryh
asked on
Managing grandchild forms with Window menu
I see that you can create forms in forms as long as you aren't trying to nest MDI windows. If you want to be able to have the ability to bring subforms to the front via a menu similar to the standard "Window" menu how would you do that?
The scenario is this:
Main form has a child form "Child" in it.
Child has "Grandchild 1" in it.
Child has "Grandchild 2" in it.
I would like a "Window" menu in Main that allows the user to select which grandchild form to bring to the front within Child. This Window menu would need to be updated whenever a "grandchild" form opens or closes in Child.
The scenario is this:
Main form has a child form "Child" in it.
Child has "Grandchild 1" in it.
Child has "Grandchild 2" in it.
I would like a "Window" menu in Main that allows the user to select which grandchild form to bring to the front within Child. This Window menu would need to be updated whenever a "grandchild" form opens or closes in Child.
You will need to find a way to get a reference to the grand children forms from the main form. Where are these forms created?
ASKER
A grandchild form would be created by way of the app menu. The grandchild form would put itself inside the child form (via childForm.Controls.Add).
Is the "app menu" on the main form?
Imagine, if you will, that I don't know anything about your application...
Imagine sitting where I sit, and dealing with vague problem descriptions...
Imagine how long this question will take to get answered...
Imagine, if you will, that I don't know anything about your application...
Imagine sitting where I sit, and dealing with vague problem descriptions...
Imagine how long this question will take to get answered...
ASKER
Sorry. I wasn't quite sure what you meant by "where was the form created".
The "app menu" is on the main MDI parent form. On the menu is a "Window" menu item. Normally that would show the list of MDI child forms. I want a group of forms (the grandchildren) to only open within a specific child form. By default the child form will show up in the Window menu but not the grandchild forms. Since you can't nest MDI forms that is as good as the WIndow menu gets by itself. Can this Window menuitem be built at run time as grandchild forms are created so that it would show the list of grandchild forms and then bring the selected grandchild form to the front?
I hope this gives you better detail.
The "app menu" is on the main MDI parent form. On the menu is a "Window" menu item. Normally that would show the list of MDI child forms. I want a group of forms (the grandchildren) to only open within a specific child form. By default the child form will show up in the Window menu but not the grandchild forms. Since you can't nest MDI forms that is as good as the WIndow menu gets by itself. Can this Window menuitem be built at run time as grandchild forms are created so that it would show the list of grandchild forms and then bring the selected grandchild form to the front?
I hope this gives you better detail.
It sounds like you are looking for code to generate MenuItem instances at run-time, right?
ASKER
I noticed the message duplication as well. I noticed that this message has 3 zones. I also noticed that it is related to another solution.
I just type text and click the "Submit" button in the "Post Comment/Solution" section at the bottom of the form. I don't do anything else. I am now going to click the "Submit" button once...
I just type text and click the "Submit" button in the "Post Comment/Solution" section at the bottom of the form. I don't do anything else. I am now going to click the "Submit" button once...
ASKER
TheLearnedOne
Yes, to generate menuitems at runtime but perhaps more importantly when those menuitems are selected to bring the associated form to the front of the other grandchild forms (all the while keeping the grandchild forms within the child form).
--I'm sorry if this message gets duplicated. I hope it doesn't but no one has discovered a solution yet.
Yes, to generate menuitems at runtime but perhaps more importantly when those menuitems are selected to bring the associated form to the front of the other grandchild forms (all the while keeping the grandchild forms within the child form).
--I'm sorry if this message gets duplicated. I hope it doesn't but no one has discovered a solution yet.
That now sounds more like you are looking to associate a MenuItem with a form when the MenuItem is clicked.
ASKER
Yes. That is correct. I want the menu to work like the standard "Window" menu in MS Windows applications but work on grandchild forms within a child form. Since you cannot nest MDIParents I figured there might be a way to simulate it.
I am still trying to understand your words, and I am honestly having a difficult time. Since I am a visual learner, I appreciate images over words. What I think would help here is if you attach a .png screen shot of what your UI looks like, so that I can gain a better understanding of your requirements.
ASKER
OK. The snapshot is attached. I would like to add menuItems to the Window menu when each new grandchild form is opened. That menuItem when clicked would bring that particular grandchild form to the front of the other grandchild forms. Does this help explain my situation?
GrandChildren.PNG
GrandChildren.PNG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for this start. When I run this I see the two grandchild forms and I can switch by clicking on their title bars or via the Window menu. One thing I noticed is that I can't bring a grandchild form to the front by simply clicking in the form. I would not have expected that. You have to click somewhere on the form's boundary (title bar or edges). If you have a text box on the grandchild forms you can click in one that's in the back and focus shifts there without bringing that form to the front.
Am I perhaps asking for too much?
Am I perhaps asking for too much?
If you have grand-child form, you can't bring it to the front of all forms. It would still be owned by the form one level up, so it would be constricted to that region. How are you creating and showing the grandchildren?
ASKER
I understand that the grandchildren forms are bound by their parent form. That is the whole reason for this exercise. I assumed that if I clicked anywhere within a grandchild form it would bring that grandchild form to the front of all other grandchild forms that belonged to the common parent. This only seems to work if I click on the form borders (including the title bar at the top of the form). This just may be a limitation of the approach. I'll have to play around with it to see if the form.Click event can be used to bring it to the front via code instead of natively.
I will mark your code sample as the accepted solution. You've been very patient with me. Thank you for your time and effort.
I will mark your code sample as the accepted solution. You've been very patient with me. Thank you for your time and effort.