Windows Develop Bookmark and Share   
 index > Windows Forms General > Mdi child also a parent work around
 

Mdi child also a parent work around

In .NET I know that you cannot have a MDI.parent that is also a child but I am wondering if there is any work arounds for this... I have a form that I open many forms inside but one of the forms that I open I would also like to be able to open forms within THAT form...

CommanderKeen  Wednesday, September 09, 2009 8:13 PM
Thanks a lot. I found that using this code

Form2 frm = new Form2();
frm.TopLevel = false;
frm.Visible = true;
frm.FormBorderStyle = FormBorderStyle.None;
frm.Dock = DockStyle.Fill;
tabControl1.TabPages[0].Controls.Add(frm);

Allows you to add a form to a tabControl.

As for the wizardPages that noBugz created. They are great; however, the only thing they do is hide the tabs on a tab control and therefore not necessary for my instance.

Thanks again.
CommanderKeen  Friday, September 11, 2009 4:56 PM
Not that I know of.

You can bring up Modal forms from MDI child forms. Don't know if that would help you ...
www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
DeborahK  Wednesday, September 09, 2009 9:25 PM
Use that insidious work around that nobugz came up with, "WizardPages". That guy's wise!
Search this forum for that word. I built a tag for it a while back. The first hit should be the one you want.

It uses a TabControl to hide the tabs. Now you just need to figure out to display forms on a TabPage.
Try to search this forum for that, too. It's been posted a few times. Unfortunately, it means a borderless form and no menus.

But, I think the WizardPages custom control will start a brainstorm.
Make you want to re-think a few things.

Rudedog =8^D
Mark the best replies as answers. "Fooling computers since 1971."
Rudedog2  Wednesday, September 09, 2009 10:33 PM
Hi CommanderKeen,

This is the thread for mentioned by Rudedog2: http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/c290832f-3b84-4200-aa4a-7a5dc4b8b5bb.
Could you let me knowif our replies help or not?

Regards,
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Friday, September 11, 2009 5:32 AM
Yes your replies help. I will check out these links. Right now my plan for a solution is take take what I previously had as a form and make this into a UserControl. I can then place these 'pseudo' forms where I please. It's the next best thing to the MDI framework. Unless these links provide a better solution. Thanks.
CommanderKeen  Friday, September 11, 2009 3:32 PM
Thanks a lot. I found that using this code

Form2 frm = new Form2();
frm.TopLevel = false;
frm.Visible = true;
frm.FormBorderStyle = FormBorderStyle.None;
frm.Dock = DockStyle.Fill;
tabControl1.TabPages[0].Controls.Add(frm);

Allows you to add a form to a tabControl.

As for the wizardPages that noBugz created. They are great; however, the only thing they do is hide the tabs on a tab control and therefore not necessary for my instance.

Thanks again.
CommanderKeen  Friday, September 11, 2009 4:56 PM
The WizardPage is great for creating UIs.
You can drop controls on the tabs at design time, yet they are hidden at runtime.
I do not think it is possible to drop a form onto tab, but you could probably drop a custom control that wraps one.

Throw in some navigation buttons to switch tabs; i.e.really like "Back", "Next" and "Cancel" that are not on the TabControl, and your done.

Mark the best replies as answers. "Fooling computers since 1971."
Rudedog2  Friday, September 11, 2009 5:20 PM
For sure. I'll probably use this later down the road, it's valuable information.
CommanderKeen  Friday, September 11, 2009 5:55 PM
Oddly enough some unexpected behavior is occuring for my particular form... There is a datagridView in one of these forms and the selection bar does not work when you place a form into a tabControl...
CommanderKeen  Friday, September 11, 2009 7:21 PM

Try this test.
Put all of the code from the .cs file and designer.cs fileinto a single new file so that you can create a new type name.
Create a new class file to do it, thencopy and paste. Be sure to rename the type, and in the constructor.
Make sure all of the code goes into one class definition.
Now instead of inheriting from Form, change it to UserControl.

Does it work?


Mark the best replies as answers. "Fooling computers since 1971."
Rudedog2  Friday, September 11, 2009 10:24 PM
Thanks I will try this test.
CommanderKeen  Friday, September 11, 2009 10:41 PM

You can use google to search for other answers

Custom Search

More Threads

• eventdelegate
• filter out some excel data and display it into datagridview
• Using arrow keys to navigate datagrid..windows 1.1
• DataGridView - gray column at left
• How do I change a font size of the text according to the control size?
• Adding a datagridviewtexboxcol at runtime
• Add button on form title bar
• ListBox
• Considering a bugreport about AutoScrollPosition property of the ScrollableControl class
• string encoding expert help needed