Click here to Skip to main content
15,886,807 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
MDIParent 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 Sample
{
    public partial class Form1 : Form
    {
        public Form()
        {
            InitializeComponent();
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {

        }



        private void newMenuItem_Click(object sender, EventArgs e)
        {


        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            From2 newMDIChild = new From2();
            newMDIChild.MdiParent = this;
            newMDIChild.Show();

        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}


Child 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 Sample
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void From2(object sender, EventArgs e)
        {

        }

        private void closebutton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Selectbutton_Click(object sender, EventArgs e)
        {
            this.Hide();
            ((Form1)this.MdiParent).Viewmenuitem.Enabled = true;

        }
    }
}


I have menus on my parent and child forms.When I run the project my menu items from my child form is appering on the parent form.But I want to enable parent form menu items from the child form?

Thanks for the help
Posted
Updated 15-Jun-11 3:16am
v2

1 solution

Hello Dear
that is so easy
just you must set property 'AllowMerge' of parent Form MenuStrip to false , default value is True . like this:

this.menuStrip1.AllowMerge = false;
 
Share this answer
 
Comments
rbjanaki 15-Jun-11 9:13am    
thanks you very much it worked
Prasanta_Prince 15-Jun-11 9:28am    
Good one.

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