0

I created a simple html editor using the IHTMLDocument2 web-browser control. My problem is, when I start typing in the web browser control, it keeps going on the same line. I have this code

HTMLEditor.DocumentText = ""; 
doc = HTMLEditor.Document.DomDocument as IHTMLDocument2; 
doc.designMode = "On"

This gives me a browser where I can start typing inside the html window. The width of this window is 440. When I start typing something and reaches the far end of the window (say I am at px 440), I was expecting the cursor to go to the next line automatically but it keesp on going and I get a scroll-bar in the window.

How can I get it to wrap to the next line?

Thanks for suggesting to use Textarea inside this document. But If I use text areat how does the following function work?

//HTMLEditor is my webbrowser contorl
private void justifybu_Click(object sender, EventArgs e)
{
    HTMLEditor.Document.ExecCommand("JustifyFull", false, null);
}

//Button2 converts rich text to html.
private void button2_Click(object sender, EventArgs e)
{
    string strHTMLWriter = HTMLEditor.DocumentText;
    richTextBox1.Text = strHTMLWriter;
    richTextBox1.Text = HTMLEditor.Document.Body.All["post-text"].InnerHtml;
    this.richTextBox1.Focus();
    this.richTextBox1.SelectAll();

}
Vic85
  • 73
  • 9
  • If it doesn't make sense, you could have asked for clarification rather than flagging it as Vague. I feel what you have done @george stocker is really vague and rubbish. – Vic85 Jun 05 '13 at 23:51
  • You haven't given us nearly enough information to go on to help you. Include some code that illustrates the problem, even a picture (plus code) would help. The minimum first step we need to be able to help you is: 1) The minimum amount of code that reproduces the problem 2) In this case, an image of what the issue looks like 3) the actual output when using the control, and 4) the expected output. If you can help us out by giving us that vital information, we can help you by answering your question. Without that, your question can't be answered. – George Stocker Jun 05 '13 at 23:56
  • Well, I had only 8 reputation points, where as I required 10 to paste an image. Now I further lost 2 points. Anyway, I will try my best to explain my problem. I have this code "HTMLEditor.DocumentText = ""; //This will get HTML editor doc = HTMLEditor.Document.DomDocument as IHTMLDocument2; doc.designMode = "On";" – Vic85 Jun 06 '13 at 00:14
  • It should go in the question, not in a comment. Click the 'edit' link. – George Stocker Jun 06 '13 at 00:18
  • OK done, How to open this question again? – Vic85 Jun 06 '13 at 00:29
  • Use a ` – Hans Passant Jun 06 '13 at 01:02
  • @Vic85 I would have, but it looks like the community beat me to it. :-) Good luck, I hope you get an answer. – George Stocker Jun 06 '13 at 01:28
  • Thanks Hans, that fixed the wrapping issue. But what if i want to edit the contents inside the text area like (BOLD,ITALIC,UNDERLINE)? Then how can i move it to my Rich Textbox with HTML code? I updated my question again. Plz check – Vic85 Jun 06 '13 at 02:27

0 Answers0