Click here to Skip to main content
15,900,644 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm playing around with MDI (I know, I know...torturing myself. I guess I like pain.) and have an issue with child form controls not showing up after setting the child form dockstyle to fill when the child form is created.

Parent Form:

C++
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace mdiparent_example
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Dispose();

        }

        private void childWindow1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form ChildForm1 = new Form();
            ChildForm1.MdiParent = this;
            // ChildForm1.FormBorderStyle = FormBorderStyle.None;
            ChildForm1.Dock = DockStyle.Fill;
            ChildForm1.Show();

        }

        private void childWindow2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form ChildForm2 = new Form();
            ChildForm2.MdiParent = this;
            // ChildForm2.FormBorderStyle = FormBorderStyle.None;
            ChildForm2.Dock = DockStyle.Fill;
            ChildForm2.Show();

        }
    }
}


Child form:

C#
namespace mdiparent_example
{
    public partial class ChildForm1 : Form
    {
        public ChildForm1()
        {
            InitializeComponent();


        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Dispose();

        }
    }
}


Both of the Child forms are the same except for their names.

Any ideas on what is causing this? What solutions might be around?

Thanks,
Sig Pimp
Posted
Comments
Sergey Alexandrovich Kryukov 13-Jul-11 3:00am    
If you like pain, think about your users -- some of them may not like pain. :-)
--SA

1 solution

Hi,

From your parent form go to properties window and set IsMdiContainer value to true
 
Share this answer
 
Comments
Sig Pimp 13-Jul-11 21:17pm    
Unfortunately, already set to "True."
Syed Salman Raza Zaidi 15-Jul-11 2:07am    
Instead of applying DockStyle here,try applying dockstyle from form properties of two child form

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900