本文介绍了如何设置子窗体的MdiParent属性在nonMDI类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作有哪些子窗体MDI应用程序。我必须表明子窗口一定条件满足一次。

I am working on MDI app which have Child Forms. I have to show Child Window once a certain conditions is met.

我创建一个单独的名为类的 clsDashbord 有法 loadDashboard() 这是应该载入frmDashboard已经设计。下面的代码所示:

I created a separate Class named clsDashbord having method loadDashboard() which is supposed to load frmDashboard already designed. Code is given below:

 public void loadDashboard(String userName)
        {
            _Dashboard = new frmDashboard();
            _Main = new frmMDI();
           // _Dashboard.MdiParent = _Main;
            _Dashboard.Text = userName;
            _Dashboard.Show();

        }



表显示不出来,如果我设置的的MdiParent 主要这是否则被显示MDI窗体的实例变量。怎么办呢

Form does not show up if I set MDIParent to Main which is instance variable of MDI Form otherwise it gets displayed. How to do it?

推荐答案

这看起来更像是通过看行一个范围的问题吗?主程序=新frmMDI();'

It looks more like a scoping problem by looking at line '_Main = new frmMDI();'

请按照下列步骤操作:


  1. 创建一个名为ReferenceTable'类

  2. 创建于ReferenceTable命名为_main一个静态变量

  3. 设置ReferenceTable._Main =新frmMain(); // Program.cs中

  4. 设置childform.Parent = ReferenceTable._Main //在所有孩子形式$ B调用展()或的ShowDialog()方法之前<$ B码/李>
  1. create a class named 'ReferenceTable'
  2. create a static variable named _Main in ReferenceTable
  3. set ReferenceTable._Main = new frmMain(); // in Program.cs
  4. set childform.Parent = ReferenceTable._Main //in all your child formcode before calling Show() or showDialog() methods

这篇关于如何设置子窗体的MdiParent属性在nonMDI类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 16:16