activate edit mode in .NET 2.0 Webbrowser Control

I am playing a little bit with the webbrowser control which is new in Winforms 2.0. Usally this is a wrapper around the mshtml control. It semes that microsoft have changed and dropped some funtctions like the ability to edit the html content. This is quite usefull in MSHTML cause you can implement your own HTML editor in a application.

This is done with the designmode property. But i didnt find it, and also object browser does not show it. Should work like

doc = WebBrowser1.Document
doc.DesignMode = "Off"

But the .NET way like

Dim doc As HtmlDocument = WebBrowser1.Document

does not give you the designmode property. I tryed to cast the htmldocument to mshtml.idocument2 but nothing.

Then i found the property activexinstance and now i got it

Dim axObj As New Object
axObj = WebBrowser1.ActiveXInstance
axObj.document.designmode =
"On"

Published Wednesday, July 13, 2005 8:09 PM by preishuber

Comments

# re: activate edit mode in .NET 2.0 Webbrowser Control

Wednesday, June 21, 2006 12:39 PM by James
Hi - I really don't know. What I need to know is how to detect an element click  ( such as an image ) when designmode = "On", i can attach the event but find that afterwhich I cannot edit it anymore.

# re: activate edit mode in .NET 2.0 Webbrowser Control

Wednesday, June 28, 2006 5:48 PM by Anthony Wieser

Dim axObj As New Object

axObj = WebBrowser1.ActiveXInstance

axObj.document.designmode = "On"

What's the type of the axObj?  do you know, since I'd like to do it in C++, instead of VB.

# re: activate edit mode in .NET 2.0 Webbrowser Control

Sunday, December 17, 2006 2:20 PM by Elan Hasson

Do a .GetType().ToString() on object and it'll tell you the type.

# re: activate edit mode in .NET 2.0 Webbrowser Control

Wednesday, April 18, 2007 11:58 PM by Matt

This doesnt work i get MemberMissing error

# re: activate edit mode in .NET 2.0 Webbrowser Control

Tuesday, December 2, 2008 1:41 PM by Phydeaux

Don't forget to set a reference to mshtml.dll and a "using mshtml" (in C#) at the beginning ... Then everything works fine.

Leave a Comment

(required) 
(required) 
(optional)
(required)