Since you can only assign it after the document have been loaded, and you don’t need to assign it every time a document loads, do I just don’t have other choice than to do something like this?
private void WebBrowser_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
if (!mouseDownAssigned) // mouseDownAssigned is a bool with start value false
{
mouseDownAssigned = true;
this.Document.MouseDown +=
new HtmlElementEventHandler(Document_MouseDown);
}
}
Which is kinda ugly and not elegant. Got a feeling this is not what Microsoft had in mind.
I think this is the closest to an elegant solution:
That way I don’t need to check a variable every time a document completes. Guess that’s kinda what Microsoft had in mind.