如何在webBrowser1单击或提交事件触发后等待webBrowser1完成加载

时间:2010-11-04 17:20:41

标签: c# browser load click submit

有无数的例子如何在导航事件

之后等待页面完全加载

但是甚至没有一个例子如何等待点击事件提交下一页完全加载

我怎么能实现这个

我想要的是在webBrowser1单击或提交(表单)事件后触发了如何等待下一页(点击或提交事件后再转到另一页)完全加载

谢谢

1 个答案:

答案 0 :(得分:0)

DocumentCompleted事件会是您想要的吗?

以下是文档页面上给出的示例。文档完全加载后,它会立即打印页面。您可以根据需要进行修改。

private void PrintHelpPage()
{
    // Create a WebBrowser instance. 
    WebBrowser webBrowserForPrinting = new WebBrowser();

    // Add an event handler that prints the document after it loads.
    webBrowserForPrinting.DocumentCompleted +=
        new WebBrowserDocumentCompletedEventHandler(PrintDocument);

    // Set the Url property to load the document.
    webBrowserForPrinting.Url = new Uri(@"\\myshare\help.html");
}

private void PrintDocument(object sender,
    WebBrowserDocumentCompletedEventArgs e)
{
    // Print the document now that it is fully loaded.
    ((WebBrowser)sender).Print();

    // Dispose the WebBrowser now that the task is complete. 
    ((WebBrowser)sender).Dispose();
}