MDIparent/Child菜单控件 [英] MDIparent/Child menu controls

查看:193
本文介绍了MDIparent/Child菜单控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MDIParent表格


MDIParent form


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

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

推荐答案

您好亲爱的
这么简单
只是您必须将父表单MenuStrip的属性``AllowMerge''设置为false,默认值为True.像这样:

this.menuStrip1.AllowMerge = false;
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;


这篇关于MDIparent/Child菜单控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆