MDI Application - Need Help

E

Eric W. Holzapfel

Hello C#,
I am trying to create an MDI app in C# (Windows
Application). I have a "container" window. I would like
to add more than one child window to the container (2 for
starters). I would like to display one child first, and
when user clicks button of child1, child1 disappears, and
child2 displays. I would prefer to have one child open at
a time. I am assuming that I can have a method in the
Parent form - that can open and close child forms.
I would like to be able to pass either the form (i.e.
Child1, or Child2, etc), and then hide/close the active
child, and display the new child.

I have seen help info for creating multiple forms, but it
is not by name, but new instances of "form x" etc.

What is the proper way to open and close child forms by
name. (I may switch from buttons on a child form, to the
menu bar scheme, etc, since it is more "Windows" like).

Thanks,

eric
 
O

Otis Mukinfus

Hello Eric,

From reading your post I have gathered that what you really want to do
is defeat the functionality of an MDI application.

MDI applications are typically used where one wants to display several
copies of the same form, each containing a different set of data. To
create one which allows one form to hide another is contrary to the
purpose of MDI applications in general.

I suggest that you consider designing your application so that it has
a parent form (not an MDI form) that displays different dialog boxes
according to menu items the user chooses from the parent form. If
your dialog boxes are generating data that you want to display, you
can display that data on the parent form.

However, if you are dead set on doing the MDI application, my first
thought of how this could be done is that you will need a way to find
out which forms are children of the MDI parent. Please understand
that I have not done this myself, so this is where I would start if I
were to try what you want to do.

You can probably get the information about the children of an MDI form
from the parent form. The first thing I would do is find out how to
get that information from within the instance of the parent form.
Then I would add a property to the MDI parent that points to this
(collection?) of children. After you have done that you should be
able to manipulate children from their siblings.

That's where I would start, Eric. I'm sure there is someone that
knows the details that I don't know about this procedure.



Hello C#,
I am trying to create an MDI app in C# (Windows
Application). I have a "container" window. I would like
to add more than one child window to the container (2 for
starters). I would like to display one child first, and
when user clicks button of child1, child1 disappears, and
child2 displays. I would prefer to have one child open at
a time. I am assuming that I can have a method in the
Parent form - that can open and close child forms.
I would like to be able to pass either the form (i.e.
Child1, or Child2, etc), and then hide/close the active
child, and display the new child.

I have seen help info for creating multiple forms, but it
is not by name, but new instances of "form x" etc.

What is the proper way to open and close child forms by
name. (I may switch from buttons on a child form, to the
menu bar scheme, etc, since it is more "Windows" like).

Thanks,

eric

Otis Mukinfus
http://www.otismukinfus.com
 
D

Darin

I have created an MDI app that is similar to what you are taking about. I
created a toolbar that let the user move from child form to child form. I
am assuming that you want only one instance of each form. What I did was
create a singleton approach for each form making sure that each form could
have only one instance. There are many ways to control opening and closing
of the child forms. The easiest is to have a toolbar on the parent form
which will give you complete control on the parent instead of putting
buttons on the child forms which makes it more complicated. If you have any
more questions do not hesitate to ask.
 

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