反射率を使ってMDIフォームを読み込みます.

2078 ワード

DevExpress.XtrabbbbbbbodMdiManagerコントロールを使ってMDIフォームをロードします.
	/// <summary>
        ///     
        /// </summary>
        /// <param name="ChildTypeString">      </param>
        /// <param name="args">  </param>
        public void OpenMDIWindow(string ChildTypeString,object[] args)
        {
            if (string.IsNullOrEmpty(ChildTypeString))
                return;
            var fullName = String.Format("{0}.{1}", GetType().Namespace, ChildTypeString);
            if (ContainMDIChild(fullName))
                return;

            // Create data type using type string
            Type typForm = Assembly.GetExecutingAssembly().GetType(fullName);
            if (typForm == null)
                return;
            // Create object using type's "InvokeMember" method
            Object obj = typForm.InvokeMember(
                null,
                BindingFlags.DeclaredOnly |
                BindingFlags.Public | BindingFlags.NonPublic |
                BindingFlags.Instance | BindingFlags.CreateInstance,
                null,
                null,
                args);

            // Show child form
            if (obj == null)
                return;
            Form myChild = obj as Form;
            myChild.MdiParent = this;
            myChild.WindowState = FormWindowState.Maximized;
            myChild.Show();
        }

	/// <summary>
        ///   MDI          
        /// </summary>
        /// <param name="ChildTypeString">      </param>
        /// <returns></returns>
        private bool ContainMDIChild(string ChildTypeString)
        {
            foreach (Form f in MdiChildren)
            {
                if (f.GetType().ToString() == ChildTypeString)
                {
                    f.Select();
                    return true;
                }
            }
            return false;
        }