3 Replies - 2286 Views - Last Post: 22 July 2011 - 12:34 PM Rate Topic: -----

#1 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1253
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

MDI child form seems to let the controls of the parent display.

Posted 22 July 2011 - 07:38 AM

Here's a small example:

A regular old form with a pictureBox and a button. Nothing fancy. In the button's click event:

private void button1_Click(object sender, EventArgs e)
{
    Form form = new Form();
    form.MdiParent = this;
    form.BackColor = Color.Red;

    form.WindowState = FormWindowState.Maximized;
    form.Show();
}


Posted Image

However, when I click on the button this happens:

Posted Image

The picturebox and the button are still showing, as if the child form were transparent. Any suggestions on how to change this? I want the child form to cover everything like a regular form.

Is This A Good Question/Topic? 0
  • +

Replies To: MDI child form seems to let the controls of the parent display.

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5509
  • View blog
  • Posts: 11,814
  • Joined: 02-June 10

Re: MDI child form seems to let the controls of the parent display.

Posted 22 July 2011 - 07:44 AM

If you comment out line 4, then it behaves as you expect, right?
Just a new form that covers everything including the calling form, right?
Was This Post Helpful? 0
  • +
  • -

#3 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1253
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: MDI child form seems to let the controls of the parent display.

Posted 22 July 2011 - 07:46 AM

Well yes, but it's not longer an MDI child of the parent form. Edit:spelling

This post has been edited by Sergio Tapia: 22 July 2011 - 07:54 AM

Was This Post Helpful? 0
  • +
  • -

#4 wiero  Icon User is offline

  • D.I.C Head

Reputation: 48
  • View blog
  • Posts: 78
  • Joined: 29-June 11

Re: MDI child form seems to let the controls of the parent display.

Posted 22 July 2011 - 12:34 PM

hi, when form is mdi parent it has additional control in it Called MdiClient. The problem you have is like when putting one button on another. MdiClient draws child forms while drawing itself. Button and image are above mdiClient. You can run this code to acctually "hide" button
 this.Controls.OfType<MdiClient>().First().BringToFront();


so i think you woudl like to add controls to mdiclient, but it only accepts child form controls and is seald which is a problem, but you can have an image in background by setting it manually
this.Controls.OfType<MdiClient>().First().BackgroundImage = Resource1.Desert;


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1