2008-02-25

WebBrowser Control Loading Hack

I was having a problem with the where I was trying to set some a the DocumentText on the load of my windows from but that browser control was not intilizied correctly and would not load the DocumentText. It took me a while but I worked out a way around it. Here is how I did it:
  1. I created a class variable called WebControlFirstLoad and set it to true.
  2. I set the DocumentCompleted event for the browser control to:
    if (!this.WebControlFirstLoad) return;
    this.WebControlFirstLoad = false
    [...load page code here...]
Now it all works fine.