Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# .NET C#4.0
Hi all..
I have big problem. I have a main form and another form which i want to use as a childmdi. i did that and it works. but the problem is that when the mdiChild appears, it goes behind of other controls. how can i fix that?
Here is my code:
            Form2 MdiChild = new Form2();
            MdiChild.MdiParent = this;
            MdiChild.Show();
Posted 28-Dec-11 9:16am
Edited 28-Dec-11 9:20am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Sounds like you have drawn controls on the MDI parent. If that is true, you should never do that. Controls are always placed on MDI children excluding status bar, menu bar etc.
  Permalink  
Comments
alizadeh91 at 28-Dec-11 15:25pm
   
How about if i want to do that??!! Isn't any way?
Mika Wendelius at 28-Dec-11 15:55pm
   
If I recall correctly, no. Basically you could hide the controls when a child form is shown but still you would have some trouble. What if part of the control drawn on MDIParent should be visible and so on.
 
If these controls on the MDIParent's area which is reserved for child forms is the problem, I think you should consider redesigning the UI.
alizadeh91 at 28-Dec-11 16:20pm
   
Ok.Thanks :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Look, listen to a good friendly advice: stop torturing yourself and chasing out your users with that MDI nonsense. Nearly everyone discourages it, and Microsoft worked hard to phase this thing out. Finally, MDI was not included in WPF even though it remains in System.Windows.Forms, presumably for compatibility with legacy code, but highly discouraged even by Microsoft where this concept was created.
 
There are many robust conceptions; the simplest one is the tabbed UI based on TabControl.
 
Please see:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^],
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to Create MDI Parent Window in WPF?[^].
 
Good luck,
—SA
  Permalink  
v3
Comments
   
MDI is perfectly viable. Just because Microsoft isn't behind it anymore doesn't mean squat. Look at all the other stuff they've abandoned - Silverlight - WinForms - C++ - unmanaged development...
SAKryukov at 30-Dec-11 10:30am
   
I agree with other stuff and partially agree with MDI -- it is viable and applicable. Formally. But in practice, I cannot see any single reason to use it, ever. Harder to develop (if one needs minimal flexibility), awkward to use.
 
I never mind using "old" technologies -- they can be better then "new" and "trendy", and I almost hate the idea of using anything "cool", but there are considerations other than that. MDI was bad at the moment of its creation.
 
Also, I don't see that Slverlight, Forms, unmanaged C++ were abandoned...
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try this:
 
MdiChild.Focus();
 
EDIT ============================
 
Try this, then:
 
MdiChild.BringToFront();
 
(Using intellisense will save you buttloads of time.)
 
EDIT #2 =========================
 
BTW, did you set your parent form's IsMDIContainer property to true?
  Permalink  
v3
Comments
alizadeh91 at 28-Dec-11 15:19pm
   
Sorry it doesn't work!!!
John Simmons / outlaw programmer at 28-Dec-11 15:25pm
   
Check my answer again.
alizadeh91 at 28-Dec-11 15:46pm
   
No it doesn't worked anyway. BringToFront bring a form to front relative to other windows forms(not it container).
Yes i made it true.
John Simmons / outlaw programmer at 28-Dec-11 17:08pm
   
Then your app needs to be refactored. Do you even know how MDI is supposed to work?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Try ZOrder method. See if this helps, http://support.microsoft.com/kb/168850[^]
  Permalink  
Comments
Mika Wendelius at 28-Dec-11 16:25pm
   
That's quite far fetched, the bug applies to VB 5. But on the other hand, you'll never know...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Although This question asked 1 year ago,i answer this.because it is question of many programmer.
 
thats so simple,you can do a trick and put all your controls on a child form and call that in mdi load event and whenever you want.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 499
1 Nirav Prabtani 298
2 OriginalGriff 215
3 _Amy 165
4 Abhinav S 160
0 OriginalGriff 7,715
1 Sergey Alexandrovich Kryukov 6,911
2 Maciej Los 3,954
3 Peter Leow 3,698
4 CHill60 2,742


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100