How to show html content using RichTextBox?

I want to show html content in my form. I tried this with a rich text box.

rtBox.Text = body;

but it does not work.

How to show html content in RichTextBox? I am using VS 2008.

+3
source share
5 answers

If you have HTML content you can use WebBrowser- otherwise you will have to convert HTML to RTF to render in RichTextBox

+3
source

Use the hidden WebBrowser control and load it with the desired html content. Then SelectAll () from WebBrowser, Copy () and Paste () in richtextbox.

WebBrowser wb = new WebBrowser(); wb.Navigate("about:blank");
string url=@"http:\\....";
wb.Navigate(url);
private const int sleepTimeMiliseconds = 200;

while (wb.ReadyState != WebBrowserReadyState.Complete)
{
Thread.Sleep(sleepTimeMiliseconds);
Application.DoEvents();
}

wb.Document.ExecCommand("SelectAll", false, null);
wb.Document.ExecCommand("Copy", false, null);
richtextbox.Paste();
+2
source

RTF HTML. . WebBrowser .

, HTML- RTF- - .

+1

, HTMl int RichTextBox, - this ( Rich TextBox).
( html).

( RichTextBox HTML Lite)

+1

, DevExpress RTF HTML.

+1

Source: https://habr.com/ru/post/1740887/


All Articles