Web Browser Control LoadCompleted Event Not Firing

2019-05-27 20:05发布

问题:

Hopefully someone can help.

I've created a user control which hosts a Web Browser control I've added this control to my new project. When I start the application and view the control the web site is loaded correctly and the LoadCompleted Event fires ok.

However I actually initialize the control from another class and ask it to navigate to the page in the background (I invoke the UI Thread), I see the navigate method get called but the LoadCompleted Event never fires until you view the form which the Web Control is hosted on.

It seems that the Web Browswer control is only rendered when the form is viewed. I need the Broswer to fully load the page because I'm invoking JavaScript functions which need to be ready for when the user looks at the form containing the web page.

Is there any way to force the browser to render the content without actually showing the page?

Thanks

回答1:

Hosted WinForms Web Browser as suggested by Noseratio.