How to use WebBrowser control DocumentCompleted event in C#?

前端 未结 5 1404
野性不改
野性不改 2020-11-27 16:14

Before starting writing this question, i was trying to solve following

// 1. navigate to page
// 2. wait until page is downloaded
// 3. read and write some d         


        
5条回答
  •  一整个雨季
    2020-11-27 16:51

    I had to do something similar. What I do is use ShDocVw directly (adding a reference to all the necessary interop assemblies to my project). Then, I do not add the WebBrowser control to my form, but the AXShDocVw.AxWebBrowser control.

    To navigate and wait I use to following method:

    private void GotoUrlAndWait(AxWebBrowser wb, string url)
    {
        object dummy = null;
        wb.Navigate(url, ref dummy, ref dummy, ref dummy, ref dummy);
    
        // Wait for the control the be initialized and ready.
        while (wb.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
            Application.DoEvents();
    }
    

提交回复
热议问题