Winforms WebBrowser webpage triggering event in the winforms application
I have a winforms application. On my fo开发者_C百科rm I have a webbroswer control. It hosts a web page. When an event is fired on the web page, such as clicking a button I wish to Hide() the form and therefore the webpage. Is this possible?
You might be trying to do something more sophisticated than what Im about to suggest, but you could handle the Navigating event on the web browser control. Perhaps do something like this:
this.webBrowser1.Navigating += new System.Windows.Forms.WebBrowserNavigatingEventHandler(this.webBrowser1_Navigating);
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e) {
e.Cancel = true;
webBrowser1.Visible = false;
}
Of course the e.Cancel will prevent the navigation request from happening (if that is what you want).
精彩评论