WinForms - HTML to RichTextBox and Vice Versa in C# and .NET

Complete code

private void btnConvert_Click(object sender, EventArgs e)
            SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf();  
            // After purchasing the license, please insert your serial number here to activate the component.
            // h.Serial = "XXXXXXXXX";

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            // 1. Convert RTF to HTML
            r.ImageStyle.IncludeImageInHtml = true;
            string html = String.Empty;
            r.ToHtml(out html);

            if (chkOpen.Checked)
                File.WriteAllText("Result.html", html);

            // 2. Convert HTML to RTF
            if (h.OpenHtml(html))
                richTextBox1.Rtf = h.ToRtf();


Private Sub btnConvert_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnConvert.Click
			Dim h As New SautinSoft.HtmlToRtf()

			h.RtfCompatibility = SautinSoft.HtmlToRtf.eRtfCompatibility.OldRtfReaders
			Dim r As New SautinSoft.RtfToHtml()

			' 1. Convert RTF to HTML
            r.ImageStyle.IncludeImageInHtml = True
            Dim html As String = Nothing
            r.ToHtml(html, Nothing)

            If chkOpen.Checked Then
                File.WriteAllText("Result.html", html)
            End If

            ' 2. Convert HTML to RTF
            richTextBox1.Rtf = h.ConvertString(html)
		End Sub
	End Class
End Namespace


If you are looking also for a .NET solution to Create or Modify HTML documents, see our Document .Net.

If you need a new code example or have a question: email us at or ask at Online Chat (right-bottom corner of this page) or use the Form below:

Questions and suggestions from you are always welcome!

We are developing .Net components since 2002. We know PDF, DOCX, RTF, HTML, XLSX and Images formats. If you need any assistance with creating, modifying or converting documents in various formats, we can help you. We will write any code example for you absolutely free.