Visual Basic/C# Workaround: WebBrowser DBLClick Word

Visual Basic/C# Workaround: WebBrowser DBLClick Word

What is this article about?


Recently in the MSDN forums (link below) it was discovered that the WebBrowser control (IE 10 based) exhibits the following unexpected behavior while used on a UserControl:
MSDN Forums - WebBrowser control standard double-click behavior not working

Certain properties modified using the property grid in design mode seem to "break" at least one known ability of the WebBrowser control (The ability to highlight a word with a double-click)
  • Known properties to cause the error
    • WebBrowser.AllowWebBrowserDrop
    • WebBrowser.ScriptErrorsSuppressed

The mentioned properties have a default value at design time. When that default value is modified using the property grid at design time, the IDE automatically generates code in the InitializeComponent sub of whatever control/form your are editing. When you change one of the default mentioned properties that code gets added to the designer, because it is no longer default, well at this point, even if you use the designer to changed it back, instead of deleting that entire line it added, it just changes the value being set in that line.

Evidence points that the error is not caused by a specific value set to the mentioned properties, but more along the lines of the fact that a value changed. This means that at the time of the unexpected behavior, the value could be true, false, or nothing, and the same error will occur. So basically, really what causes the problem is the existence of code in the initializeComponent sub that modifies the mentioned properties (regardless of the value being modified to).


*It is quite possible other properties could have a similar issue... Which I imagine the soon to be explained workaround would also apply...

Workaround

Very simple

  • Do not use the property grid to modify the mentioned properties.
  • Comment out any designer generated code that may have modified the mentioned properties.
  • Find a load event to modify the properties from code, instead of using the property grid (designer).
  • Modifying the webbrowser's properties from the usercontrol's load event might work.
  • Instead if it doesn't, then modify the properties from the load event of the form that contains the usercontrol.

References

This article is a brief overview of the problem. Visit the original forum post here.

I hope you find this helpful!

no registration counter
Visitors Counter
Leave a Comment
  • Please add 3 and 6 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
  • Richard Mueller edited Revision 9. Comment: Removed tags "visual" and "studio", but left tag "Visual Studio". I don't see value in the first two.

  • Naomi  N edited Revision 3. Comment: Minor edit

  • Maheshkumar S Tiwari edited Revision 2. Comment: Added TOC and formatting

  • Paul Ishak edited Revision 1. Comment: small edit

  • Paul Ishak edited Original. Comment: add hit counter

Page 1 of 1 (5 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Paul Ishak edited Original. Comment: add hit counter

  • Paul Ishak edited Revision 1. Comment: small edit

  • Maheshkumar S Tiwari edited Revision 2. Comment: Added TOC and formatting

  • Naomi  N edited Revision 3. Comment: Minor edit

  • This article may benefit from See Also section. I saw recently another interesting article about WebBrowser control

  • Richard Mueller edited Revision 9. Comment: Removed tags "visual" and "studio", but left tag "Visual Studio". I don't see value in the first two.

Page 1 of 1 (6 items)