只有顶级控件才能拥有所有者。 [英] Only top-level controls can have an owner.

查看:413
本文介绍了只有顶级控件才能拥有所有者。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用过Metro工具。我也创建了Mdi Parent表单。当我将父表单传递给子表单时,会显示错误消息。喜欢只有顶级控件可以拥有一个拥有者



如何解决这个问题?请给我解决方案



 使用 MetroFramework.Forms; 
使用系统;
使用 System.Collections.Generic;
使用 System.ComponentModel;
使用 System.Data;
使用 System.Drawing;
使用 System.Linq;
使用 System.Text;
使用 System.Threading.Tasks;
使用 System.Windows.Forms;
使用 BillingSystem.Presentation;

命名空间 BillingSystem.Presentation
{
public partial class frmMainMenu:MetroForm
{
public frmMainMenu()
{
InitializeComponent();
}
public void LoadForm(MetroForm frm)
{
frm.MdiParent = ;
frm.WindowState = FormWindowState.Maximized;
frm.BringToFront();
frm.Show();
}
private void frmMainMenu_Load( object sender,EventArgs e)
{

}

private void metroButton2_Click( object sender,EventArgs e)
{
尝试
{
LoadForm( new frmAddInvoice());
this .WindowState = FormWindowState.Maximized;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}





我尝试了什么:



错误显示在frm.show()...

解决方案

< blockquote>您使用MDI的目的不是为了它。根据您发布的代码判断,您根本不需要MDI。 MDI也非常不赞成。



MDI适用于编辑等应用程序,您可以同时打开多个文档,但文档都是相同的编辑器。有点像打开多个Notepad但在同一个应用程序中。



什么是MetroForm?它似乎不是一个真正的表格。


i have used Metro tools. and i have created Mdi Parent form also. when i pass "parent form" to "child form" errors message are displays. like "Only top-level controls can have an owner"

how to fix this issues? please give me solution

using MetroFramework.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BillingSystem.Presentation;

namespace BillingSystem.Presentation
{
    public partial class frmMainMenu : MetroForm
    {
        public frmMainMenu()
        {
            InitializeComponent();
        }
        public void LoadForm(MetroForm frm)
        {
            frm.MdiParent = this;
            frm.WindowState = FormWindowState.Maximized;
            frm.BringToFront();
            frm.Show();                               
        }
        private void frmMainMenu_Load(object sender, EventArgs e)
        {
           
        }
    
        private void metroButton2_Click(object sender, EventArgs e)
        {
            try
            {
                LoadForm(new frmAddInvoice());
                this.WindowState = FormWindowState.Maximized;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }        
    }
}



What I have tried:

The Error's shows in "frm.show()"...

解决方案

You're using MDI for a purpose it was not intended. Judging by the code you've posted, you don't need MDI at all. MDI is also pretty much deprecated.

MDI was intended for applications like editors, where you have multiple documents open at the same time, but the documents are all the same editor. Kind of like having multiple Notepads open but in the same application.

What is "MetroForm"? It doesn't appear as though that is an actual Form.


这篇关于只有顶级控件才能拥有所有者。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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