C# 通过方法显示所有子窗体

C# 通过方法显示所有子窗体,c#,mdichild,mdiparent,C#,Mdichild,Mdiparent,我有一个mdi表单,主菜单上有很多子表单,我使用这些代码打开子表单: frmCustomers yeni = new frmCustomers(); if (GenelIslemler.formAuthCheck(yeni.Name.ToString())) { if (!IsOpen(yeni.Name.ToString())) { yeni.MdiParent =

我有一个mdi表单,主菜单上有很多子表单,我使用这些代码打开子表单:

        frmCustomers yeni = new frmCustomers();
        if (GenelIslemler.formAuthCheck(yeni.Name.ToString()))
        {
            if (!IsOpen(yeni.Name.ToString()))
            {
                yeni.MdiParent = this;
                yeni.WindowState = FormWindowState.Maximized;
                yeni.Show();

            }
        }
        else
        {
            MessageBox.Show("You dont have rights to access!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
但是我想写一个方法,然后调用这个方法的表单,就像

openForm(FRM客户)

openForm方法应该是这样的

openForm(表格frm) {…}


我该怎么做?

这是为每个网络应用程序内置的反射系统所做的工作

using System.Reflection;

private void openForm(string formName)
{
    // First check if this form is authorized 
    if (GenelIslemler.formAuthCheck(formName))
    {
        // Then check if is already opened
        if (!IsOpen(formName))
        {
            // And now transform that string variable in the actual form to open

            // This is the critical line. You need the fully qualified form name. 
            // namespace + classname 
            Type formType = Type.GetType ("RapunzoApps.ThisApp." + formName);
            ConstructorInfo ctorInfo = formType.GetConstructor(Type.EmptyTypes);
            Form theForm = (Form) ctorInfo.Invoke (null);
            theForm.MdiParent = this;
            theForm.WindowState = FormWindowState.Maximized;
            theForm.Show();
        }
    }
    else
    {
        MessageBox.Show("You dont have rights to access!", "uyarı", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}