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.
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.
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();