C#窗体应用程序中webBrowser控件中的网页完全复制到另一个窗口中的webBrowser控件中

来源:百度知道 编辑:UC知道 时间:2024/06/18 04:11:50
现在有一个窗体Form1,里面有一个webBrowser控件和一个按钮,webBrowser中显示某银行的网银帐号登录界面,我现在先登录到我的网银帐号,然后单击窗体中的Button按钮,弹出另一个窗口Form2,要求在此窗口中的webBrowser控件中完全显示Form1中webBrowser控件中的网页,好比是将Form1中的webBrowser控件最大化,但不同的是在另一个控件显示。求高人相助!!
注:不是传一个uri就能解决问题的,如果这样,在Form2中控件里的网页就会回到登录界面,而我要求的是Form1中控件显示登录后的页面,Form2中控件也显示登录后的页面。我现在贴出我写的不对的代码。

Form1
private void button5_Click(object sender, EventArgs e) //最大化
{
Form2 form22 = new Form2();
form22.Tag = webBrowser1.Tag;
//form22.wbr.Url = this.webBrowser1.Url;
form22.url = this.webBrowser1.Url.ToString();

form22.ShowDialog();
}

以下是Form2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using mshtml;

namespace HsBankQueryDe

Form1:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void btn_Create_Click(object sender, EventArgs e)
{
Form2 f = new Form2(this.webBrowser1.Url.ToString());
f.ShowDialog();
}
}
Form2:
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

public Form2(string url)
: this()
{
this.webBrowser1.Url = new Uri(url);
}
}