2

In a WinForms application I need to detect when the contents of a System.Windows.Forms.WebBrowser is double clicked which in turn opens custom winform dialog box.

I note that WebBrowserBase disables the Control.DoubleClick event but I've not worked out how to override this behaviour.

1 Answer 1

11

MouseDown is disabled too. That's because mouse events are sent to the DOM. You can subscribe to DOM events with the HtmlElement.AttachEventHandler() method. For example:

public partial class Form1 : Form { public Form1() { InitializeComponent(); webBrowser1.Url = new Uri("http://stackoverflow.com"); webBrowser1.DocumentCompleted += webBrowser1_DocumentCompleted; } void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { webBrowser1.Document.Body.AttachEventHandler("ondblclick", Document_DoubleClick); } void Document_DoubleClick(object sender, EventArgs e) { MessageBox.Show("double click!"); } } 
Sign up to request clarification or add additional context in comments.

1 Comment

Tried the solution today and it still works...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.