WebBrowserDocumentCompleted

WebBrowserDocumentCompleted

假设我有一个这样的功能:

public TestStuff() {

    string testing = "test";
    webBrowser2.Navigate("http://google.com");
    webBrowser2.DocumentCompleted += WebBrowserDocumentCompleted;

}

public WebBrowserDocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs Url) {

    MessageBox.Show(testing);
}


如何通过测试进入WebBrowserDocumentCompleted函数?我不确定在语法上如何将其添加为参数。

最佳答案

利用closures轻松

public void TestStuff()
{
    string testing = "test";
    webBrowser2.DocumentCompleted += (s, e) =>
        {
            MessageBox.Show(testing);
        };
    webBrowser2.Navigate("http://google.com");
}

关于c# - 将参数传递到WebBrowserDocumentCompleted,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18282954/

10-10 18:13