I want to show html contents in my form. I tried to it with rich text box.
rtBox.Text = body;
but it fails.
How to show html contents in RichTextBox? I am using VS 2008.
Presents code to display bindable HTML text in a WPF RichTextBox or a WebBrowser.
In the Content Type Builder page, add the Rich Text Editor (RTE) field to it. In the Edit Properties section of the RTE field, under Editor Version, select Latest. Under the Editor Type, select Custom, and choose the formatting options you want to include in the RTE field.
For example, editing a document, article, or blog that requires formatting, images, etc is best accomplished using a RichTextBox. A TextBox requires less system resources than a RichTextBox and it is ideal when only plain text needs to be edited (i.e. usage in forms).
If you've got HTML content, you could use the WebBrowser
control - otherwise you will have to convert the HTML to RTF to render in the RichTextBox
Use a hidden WebBrowser Control and load it with the html content you want. Then SelectAll() from the WebBrowser, Copy(), and Paste() into the 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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With