Why is WebBrowser_DocumentCompleted() firing twice?

前端 未结 9 1374
独厮守ぢ
独厮守ぢ 2020-11-29 08:35

Well, I\'m using a simple webbrowser control to browse to a page, so I need to change the Text of the form while doing so. I\'m using -

private void webBrow         


        
9条回答
  •  情歌与酒
    2020-11-29 09:18

    I have the same problem, and the reason was because, by default when you add the control it generate designer code like this.

    this.webBrowser1.Url =  new System.Uri("", System.UriKind.Relative);
    

    and if you change the url after calling

    InitializeComponent();
    WebBrowser.Navigate("NewUrl.com");
    

    It will load two different pages: About:Blank and NewUrl.com

    Just, remove the designer code... and you'll stop the "double" event.

提交回复
热议问题