NOTE: This is about the control's built-in behavior, not about creating a double-click event.
One of my projects uses the Windows.Forms.WebBrowser control as an editor and viewer for HTML. It has been working fine for years but suddenly I noticed that before when I would double-click it would automatically select the word which was clicked (this was not my code, just happened with the control).
Suddenly (not exactly sure when), double clicking text in the control (both in edit mode or in view mode) does nothing. It's hard to troubleshoot because it is not my code doing it, however, since I depended on this functionality in the past, it is now impacting my final product.
Any idea what would have recently changed (in Windows or in .Net) which would affected this (the same version of my app works fine in older Win7 but not in the most up-to-date Win7)? Also, how can I get the previous functionality back? Must I wire up my own double-click even on the DOM and then start parsing the text to manually select it (uh!)?
I've looked all over for the answer to this question but mostly I just see how to wire up to DOM events, nothing about recent changes which would cause the problem above). Any help would be greatly appreciated.
I'm using VS 2010, VB, Win7 x64, IE 10.0.6, .Net 3.5 (whatever the latest one is) when the problem happens (compiled so I doubt it is VS or VB).
When I run the exact same code (compiled) on Win7 x86 with IE 8 (Win7 Pro plain, with zero-updates installed) it works just fine.
After some further testing, on the Win7 x86 fresh install (where everything was fine) as soon as I install IE 10 and NOTHING ELSE the problem starts to happen. So, I'm pretty sure the problem lies with IE 10.
Steps to reproduce:
Add this code to the usercontrol
Public Sub LoadHTML(html As String)
WebBrowser1.DocumentText = html
Do Until WebBrowser1.ReadyState = WebBrowserReadyState.Complete
Application.DoEvents()
Loop
WebBrowser1.Document.Body.SetAttribute("contentEditable", "false")
End Sub
Add that control to a form
Add a button to the form with the following button.Click event:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
UserControl1.LoadHTML("<html><body>This is a test interesting is it not?</body></html>")
End Sub
Run the project and click the button
If you throw the webbrowser control directly on the form, it will work fine. The problem is with the usercontrol (and it is only a problem after updating to IE10).
I can reproduce the problem using VS 2010 using .Net 3.5 and 4.0. I can reproduce the problem using VS 2012 using .Net 4.5.
The problem is actually a bug in IE 10. This was confirmed by Microsoft here.
The saddest part is that they said they would not be fixing it any time soon (if ever) because it affects too few people (though it does affect thousands of my company's customers).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With