• (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4

Creating a wysiwyg HTML editor in C# Using the MS HTML Object Library

#31 Black0n3  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 07-April 10

Posted 09 May 2010 - 12:33 PM

View Postsandrocirlini, on 16 March 2010 - 07:28 AM, said:

how can i disable the automatic showdialogAttachment ew.gif?

I have the same problem. When I try to delete all text I have get same message:
This document has been modified, do you want to save changes?

how can I disable that message?

I use this to delete text:
HTMLEditor.DocumentText = ""
Was This Post Helpful? 0
  • +
  • -

#32 Guest_clone1018*


Reputation:

Posted 25 May 2010 - 04:11 PM

Error 1 'System.Windows.Forms.WebBrowser' does not contain a definition for 'document' and no extension method 'document' accepting a first argument of type 'System.Windows.Forms.WebBrowser' could be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\clone1018\My Documents\Visual Studio 2008\Projects\AxximPHP\AxximPHP\Form1.cs 28 24 AxximPHP


Thats the error I get. Any clues?
        private IHTMLDocument2 doc;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            HTMLEditor.DocumentText = "<html><body></body></html>"; //This will get our HTML editor ready, inserting common HTML blocks into the document
            //Make the web 'browser' an editable HTML field

            doc = HTMLEditor.document.DomDocument as IHTMLDocument2;
            doc.designMode = "On";
            //What we just did was make our web browser editable!
        }


Was This Post Helpful? 0

#33 Guest_Ron*


Reputation:

Posted 02 June 2010 - 07:13 PM

Thank you for the tutorial, very good!

I'm wondering how I'd move the cursor back to the starting position of the document after I've pasted in some text?



thanks,
Ron
Was This Post Helpful? 0

#34 Guest_Craig*


Reputation:

Posted 20 July 2010 - 11:03 AM

This is a great tutorial. I am having trouble getting spell-check implemented with this :(
Was This Post Helpful? 0

#35 iDevelop  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 1
  • Joined: 18-August 10

Posted 18 August 2010 - 02:37 PM

May I use this code in a commercial product?

I assume I can as the MSHTML is included with Windows. [correct?]

Thanks for the answer!
Was This Post Helpful? -1
  • +
  • -

#36 Themitchel0  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 107
  • Joined: 14-April 10

Posted 21 August 2010 - 03:23 PM

@ idevelop id think that you can, but should change it alot, not just copy this, because that would be like cheating.

@ aj32 can you reprovide the picture at the begninng, because i cannot see it :(

thank you!
Was This Post Helpful? 0
  • +
  • -

#37 Guest_wiegerthefarmer*


Reputation:

Posted 07 September 2010 - 07:11 AM

I have the same problem. Did you get it resolved?

View PostScotty G, on 09 April 2010 - 12:17 PM, said:

Hello, I'm playing around with this editor and I love the tutorial! The only problem I'm having is when I try to place any starting text in the web form. Every time I do the:

doc.selection.createRange() as IHTMLTxtRange;



vs(2005) gives me the error: Error HRESULT E_FAIL has been returned from a call to a COM component.

Do you have any idea why this is happening?

Was This Post Helpful? 0

#38 Mira_bg  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-September 10

Posted 09 September 2010 - 02:15 AM

Very clear code snippet. Thank you! Only one note- you shoud use HTMLEditor.Document instead of HTMLEditor.document.

This post has been edited by Mira_bg: 10 September 2010 - 12:15 AM

Was This Post Helpful? 0
  • +
  • -

#39 Guest_kanmcuno*


Reputation:

Posted 15 September 2010 - 11:31 AM

How do you get the Enter key to input <br> instead of <p></p>. I know that I can use "shift + enter" to input a <br>. I've tried using the send keys but unable to get this to work.
Was This Post Helpful? 0

#40 Guest_Justin*


Reputation:

Posted 01 January 2011 - 11:33 AM

strHTMLWriter = HtmlEditor1.HTMLText
strHTMLWriter = Replace(strHTMLWriter, "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">", "")
strHTMLWriter = Replace(strHTMLWriter, "<HTML><HEAD>", "")
strHTMLWriter = Replace(strHTMLWriter, "<META content=""text/html; charset=utf-8"" http-equiv=Content-Type>", "")


strHTMLWriter = Replace(strHTMLWriter, "</HEAD>", "")
strHTMLWriter = Replace(strHTMLWriter, "<BODY>", "")
strHTMLWriter = Replace(strHTMLWriter, "</BODY></HTML>", "")

'Get rid of meta tag
strHTMLWriter = Replace(strHTMLWriter, "<META name=GENERATOR content=""MSHTML 9.00.7930.16406"">", "")
strHTMLWriter = Replace(strHTMLWriter, "<META name=GENERATOR content=""MSHTML 8.00.7600.16385"">", "")

Dim intStartChar, intEndChar As Integer
intStartChar = strHTMLWriter.IndexOf("<META")
intEndChar = strHTMLWriter.IndexOf(">")
strHTMLWriter = strHTMLWriter.Remove(intStartChar, intEndChar - intStartChar + 1)

'Get rid of spaces on either side
strHTMLWriter = strHTMLWriter.Trim
Was This Post Helpful? 0

#41 habe8  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-March 11

Posted 08 March 2011 - 02:27 PM

Now: 2011 using c# VS 2010

using mshtml; wrong!
using MSHTML; is ok.

doc =
HTMLEditor.document.DomDocument as IHTMLDocument2; wrong

doc =
HTMLEditor.Document.DomDocument as IHTMLDocument2; is ok
Was This Post Helpful? 0
  • +
  • -

#42 Neyte  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-March 11

Posted 21 March 2011 - 11:33 AM

View PostBlack0n3, on 09 May 2010 - 12:33 PM, said:

View Postsandrocirlini, on 16 March 2010 - 07:28 AM, said:

how can i disable the automatic showdialogAttachment ew.gif?

I have the same problem. When I try to delete all text I have get same message:
This document has been modified, do you want to save changes?

how can I disable that message?

I use this to delete text:
HTMLEditor.DocumentText = ""

Hello , I have the same problem , have you find the solution ?

This post has been edited by Neyte: 21 March 2011 - 11:33 AM

Was This Post Helpful? 0
  • +
  • -

#43 mmtzh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-April 11

Posted 11 April 2011 - 09:43 AM

hey ho

1. thanks for this great tutorial.

But i've still a question.

When I want to change the source (or anything else) of an image, then I want to display all the properties of the image before changeing.

But how can I get the properties of a marked picture in the webbrowser ???

I allready found how to get the content of marked text - but this doesn't work with images

Can someone help me ?

i hope you understood me - my english is not so good
Was This Post Helpful? 0
  • +
  • -

#44 nassausky  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-February 12

Posted 14 February 2012 - 10:46 AM

A couple years later for anyone still trying something like this out. If you are also creating a richedit control to work with the code, turning on the "AllowNavigation" to True will stop the following annoyance:
-----------------
"This document has been modified. Do you want to save changes?"
"Yes: Saves your changes"
"No: Discards your changes"
"Cancel: Keeps this document open"
Yes/No/Cancel buttons.
-----------------
Was This Post Helpful? 0
  • +
  • -

#45 frojd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-April 12

Posted 30 April 2012 - 05:47 AM

Excellent tutorial. I need relative path (in html image tag) when user try to insert image. Is it possible?
Was This Post Helpful? 0
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4