Scott
Scott

Reputation: 6261

Displaying HTML content inside of a textbox

I'm using the following code, to get my raw HTML string from the URL and display it inside of a (rich) textbox form:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.TransparencyKey = Me.BackColor
    Dim client As WebClient = New WebClient()
    RichTextBox1.Text = client.DownloadString("http://myurl.com/raw.php")
End Sub

The problem is that, the HTML string isn't converted and I can see the HTML tags inside of a textbox text I mean the Hello <strong>World</strong> isnt converted into the "Hello World".

I know I can use a WebBrowser object, but I would like to set its background color from the white to transparent and that is not allowed as far as I know. Another reason I dont want to use WebBrowser are links, because when the downloaded string has some <a href="...">...</a> tags, it would be converted but when I would like it to be opened with a default browser, instead of a typical location change in a box.

Is there any solution for this?

Upvotes: 1

Views: 17365

Answers (1)

Sani Huttunen
Sani Huttunen

Reputation: 24395

A TextBox cannot render HTML. What you need is a modified RichTextBox control that handles HTML. This might help you get started atleast.

Then there's the HtmlTextbox for Windows.Forms control which might suite your needs.

Upvotes: 2

Related Questions