Windows Develop Bookmark and Share   
 index > Windows Forms General > MDI Child Form TopMost problem ..
 

MDI Child Form TopMost problem ..

I have a MDI application, Form1 is parent form and Form2 is a child form.
On parent form(Form1) i put a textbox1 and button1
Then i call show method to show child form by click button1
this is my code.

private void button1_Click(object sender, EventArgs e)
{
Form2 frmChild = new Form2();
frmChild.MdiParent = this;
frmChild.TopMost = true;
frmChild.BringToFront();
}

The problem is... when when child form (frmChild) is displayed,
textbox1 and button1 is still on the top.
How to solve this, so that textbox1 and button1 is behind the form frmChild when the frmChild is displayed?
Thanks..







bullfreak  Sunday, September 21, 2008 5:52 AM
Did you put textBox1 and button1 on the parent? You'll need to put them in a panel that you dock on one of the sides of the parent.
nobugz  Sunday, September 21, 2008 1:52 PM

Hi bullfreak,

Please try to use MDIClient which represent the container for multiple-document interface child forms. You can set the MDIClient as the parent container to the controls which is in the parent form.

Please refer to this thread for a simple implementation written by Rong-Chun Zhang.

Best Regards,

Bruce Zhou

Windows Forms General FAQs
Windows Forms Data Controls and Databinding FAQs

Bruce.Zhou  Tuesday, September 23, 2008 7:14 AM
Great..It's Work now. Thanks Bruce Zhou.

bullfreak  Wednesday, September 24, 2008 3:57 AM
Hi!

The only way to solve this would be to set the .Visible property of all your controls on the Form1 form to false. From what I know, you can't have them visible and also the mdi child on top.

Regards,
Lucian Baciu  Sunday, September 21, 2008 8:58 AM
Did you put textBox1 and button1 on the parent? You'll need to put them in a panel that you dock on one of the sides of the parent.
nobugz  Sunday, September 21, 2008 1:52 PM
OK. I have create a panel and put it on parent and set Dock to Fill
When i call frmChild.show(), i can not the frmChild. Because it's still behind the panel.
Still not work...
Any Idea please ? thanks


bullfreak  Monday, September 22, 2008 8:01 AM
"dock on one of the sides" was the key phrase in my post.
nobugz  Monday, September 22, 2008 8:29 AM
Ok. I have dock it on one of the sides on parent form. but still not work..
the child form is still behind the panel.
Any Idea please..?
thanks

bullfreak  Monday, September 22, 2008 4:03 PM

Hi bullfreak,

Please try to use MDIClient which represent the container for multiple-document interface child forms. You can set the MDIClient as the parent container to the controls which is in the parent form.

Please refer to this thread for a simple implementation written by Rong-Chun Zhang.

Best Regards,

Bruce Zhou

Windows Forms General FAQs
Windows Forms Data Controls and Databinding FAQs

Bruce.Zhou  Tuesday, September 23, 2008 7:14 AM
Great..It's Work now. Thanks Bruce Zhou.

bullfreak  Wednesday, September 24, 2008 3:57 AM

You can use google to search for other answers

Custom Search

More Threads

• Numerical Output from 2 textboxes is summed in the third
• Form with unmanaged LoadLibrary error to send struct with data.
• Loading User Controls using Command Patterns
• TreeView mouse rightclick highlight problem
• exception on datagridview
• KeyPressedEvent for the key "ENTER" is causing an unwanted beep.
• DataGridView NotifyCurrentCellDirty usage
• How can I handle in the child class an event raised in the parent class?
• WebBrowser control using Proxy ?
• MessageBox in c#