我有两个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();
}
}
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();
}
}
childForm.MdiParent = parentForm;
下載地址:http://dormforce.net/Blog/Attachment/793
2. 自己寫也行抓包程序
3. 自己寫一程序,使用WebBrowser做瀏覽器,每一個頁面加載時加入js,獲取cookies
frmAddProduct childForm=new frmAddProduct();
childForm.TopLevel = false;
childForm.Parent = parentForm; //也可使用MdiParent
childForm.Controls.Add(childForm);
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);
}