Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am passing a html content from a richtextbox to webbrowsercontrol
WebBrowser1.DocumentText = richtextbox1.Text

and the web control is showing converted HTML. Good !!

but it is not allowing me to edit the converted html (like to change the message) in webbrowser control.
when i use

WebBrowser1.Document.ExecCommand("EditMode", False, DBNull.Value)

this clears off everything in the webbrowser control allowing me to write.

Any idea how i can edit my message in webbrowercontrol ?
Posted

I haven't tried this, but you can try the DesignMode Property:

VB
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        obj = WebBrowser1.ActiveXInstance
        obj.document.designmode = "On"
        Application.DoEvents()
    End Sub


'To Bold Text
WebBrowser1.Document.ExecCommand("Bold", False, Nothing)


'To Underline Text
WebBrowser1.Document.ExecCommand("Underline", False, Nothing)


'To Italisize Text
WebBrowser1.Document.ExecCommand("Italic", False, Nothing)


'To Set Text Font
WebBrowser1.Document.ExecCommand("FontName", False, "Calibri")


'To Set Text Font color
WebBrowser1.Document.ExecCommand("ForeColor", False, Color.Red)


'To Set Text Back Color
WebBrowser1.Document.ExecCommand("BackColor", False, ColorDialog1.Color)


'To Align Left
WebBrowser1.Document.ExecCommand("JustifyLeft", False, Nothing)


'To Centre Align
WebBrowser1.Document.ExecCommand("JustifyCenter", False, Nothing)


'To Right Align
WebBrowser1.Document.ExecCommand("JustifyRight", False, Nothing)
 
Share this answer
 
Comments
ramathirtha randhi 18-Jun-14 9:42am    
It is clearing my copied HTML from richtext box, when i use the above code
Set the DocumentText property after event WebBrowser1_DocumentCompleted
 
Share this answer
 
and hot to add a picture usin that command
 
Share this answer
 
and how to add a picture usin that command... i want to insert a picture
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900