标题:[请教] 我的这段代码怎么一到执行打开子窗口的时候,就提示错误呢?
只看楼主
huangweia0
Rank: 1
等 级:新手上路
帖 子:50
专家分:0
注 册:2005-3-8
结帖率:33.33%
已结贴  问题点数:20 回复次数:1 
[请教] 我的这段代码怎么一到执行打开子窗口的时候,就提示错误呢?
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace 图书管理系统
{
    /// <summary>
    /// Description of MainForm.
    /// </summary>
    public partial class MainForm : Form
    {
        public MainForm()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            
            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //
        }
        
        private bool checkChildFrmExist(string childFrmName)
        {
            foreach(Form childFrm in this.MdiChildren)
            {
                if(childFrm.Name == childFrmName) //用子窗体的Name进行判断,如果存在则将他激活
                {
                    if(childFrm.WindowState == FormWindowState.Minimized)
                        childFrm.WindowState = FormWindowState.Normal;
                    childFrm.Activate();
                    return true;
                }
            }
            return false;
        }

        private void 退出ToolStripMenuItem1Click(object sender, EventArgs e)
        {
            this.Close();
            return;
        }
        
        private void 关于ToolStripMenuItem1Click(object sender, EventArgs e)
        {
            about SubForm = new about();
            SubForm.ShowDialog();
        }
        
        private void 藏书管理ToolStripMenuItemClick(object sender, EventArgs e)
        {
            if (this.checkChildFrmExist("cangshu") == true)
            {
                return;
            }
            cangshu newFom = new cangshu();
            newFom.MdiParent = this;
            newFom.Show();
        }
    }
}

请教上述代码中,为什么一打开菜单中的子窗口就会提示newFom.MdiParent = this;这一句有问题呢。我用sharpdevelop的。
搜索更多相关主题的帖子: Windows required support 管理系统 public 
2011-07-20 22:05
girl0001
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:56
专家分:118
注 册:2010-7-17
得分:20 
将MainForm 设置为this.IsMdiContainer=true
2011-07-24 10:34



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-345760-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.440840 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved