我有两个form:frmMain,frmAddProduct,我在frmMain中想显示frmAddProduct,frmAddProduct上有添加产品的控件了,怎么解决啊?
        private void frmMain_Load(object sender, EventArgs e)
        {
            //this.Hide();
            //frmAddProduct frm = new frmAddProduct();
            //frm.ShowDialog();
            Common common = new Common();
            common.ShowChildForm(frmAddProduct.CreateObject(), this, true);
        }
common.cs:
        public  void ShowChildForm(System.Windows.Forms.Form childForm, System.Windows.Forms.Form parentForm, bool isModalWin)
        {
            if (childForm != null)
            {
                childForm.MdiParent = parentForm;
                if (isModalWin)
                    childForm.ShowDialog();                   //error    
                    //Form that is not a top-level form cannot be displayed as a modal dialog box. Remove the form from any parent form before calling showDialog.
                else
                    childForm.Show();
            }
        }

解决方案 »

  1.   

     childForm.TopLevel = false;
                childForm.MdiParent = parentForm;
      

  2.   

    1. 可以用HttpAnalyzer等Http分析軟件
    下載地址:http://dormforce.net/Blog/Attachment/793
    2. 自己寫也行抓包程序
    3. 自己寫一程序,使用WebBrowser做瀏覽器,每一個頁面加載時加入js,獲取cookies
      

  3.   


     frmAddProduct childForm=new frmAddProduct();
     childForm.TopLevel = false;
     childForm.Parent = parentForm;         //也可使用MdiParent
     childForm.Controls.Add(childForm);     
      

  4.   

    原因就是TopLevel 为true的控件不能切入到其他容器中,form默认的TopLevel 是true,写代码英文还是要会一些的
      

  5.   

    我这样写没有问题:
            private void frmMain_Load(object sender, EventArgs e)
            {
                //this.Hide();
                frmAddProduct frm = new frmAddProduct();
                frm.ShowDialog();
                //Common common = new Common();
                //ommon.ShowChildForm(frmAddProduct.CreateObject(), this, true);
            }
      

  6.   

    mdi子窗体是不能showdialog方式显示的,这个是windows的规定也是开发基本常识