Click here to Skip to main content
15,354,006 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everybody, I'm having a little but frustrating problem here. In the project I'm working on right now I programmed a WYSIWYG HTML editor with a richtextbox for the codeview and a webbrowser for the editable preview and they are both updating each other depending on which of them are changes made. So far so good. Whats frusttrating for me is that it seems that i can't by any means disable the auto textwrap of the richtextbox when I change the text like:

rTBxCode.Text = WBHTML.DocumentText;

I always get the HTML text blobbed together and it's hard to make sense of the syntax that way. is there a way to keep the format and linebreaks? I would apreciate any help.

i pass the richtextbox to the webbrowser in this way:

    string current_source = rTBxCode.Text;
    StreamWriter stream = new StreamWriter("index.html");
    string place = Directory.GetCurrentDirectory();
    string url = place + "/index.html";
catch (Exception ex)
    CreateLogFiles log = new CreateLogFiles();
    log.ErrorLog("C:\\", "Error HTMLEditor time2_tick funcion. " +ex.Message , "ProgrammErrorLog.txt");
Gregory Gadow 5-Oct-11 9:37am
The first thing to check is: are the line breaks you want being given to WBHTML in the first place? Try adding Debug.WriteLine(WBHTML.DocumentText) after the call to Navigate; it may be that the text box is faithfully displaying exactly what it is being given to display.
Mendor81 6-Oct-11 2:38am
Your are right, I checked both moments when i pass the HTML written in the RTB to the webbrowser (then its passed with the linebreaks and correct format, but after the webbrowser navigated and i return the documenttext to the RTB it comes back blobbed. so it seems the webbrowser is messing up the is that possible? and more important how can i fix that if there is a way.

1 solution

You might start by examining other strategies for converting RTF to HTML, such as by using XSL, as in this CP article: "XHTML2RTF: An HTML to RTF conversion tool based on XSL"[^].

And check out this MSDN article: "Converting between RTF and HTML"[^].

Have you done any 'archaeology' on how an RTF file tells its consumers that word-wrap is "on" ?

best, Bill

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