
Introduction
Now this may seem like a strange control to create. I mean, the RichTextBox can do almost anything you need. The idea for this came when I was making my AIM Custom Client. For those of you that don't know, AOL released an SDK that can access the AIM network, which leads me to my point. The AIM network uses an HTML type formatting. Seemed easy enough at first, since I just needed to convert text. But then came the problems of the tag not being able to show the same size as rtf font size, the AIM UI not recognizing the tag, etc. So I just made this control to help me out a bit, and put it on here in case anyone needed text in HTML format.
How It Works
This control was simple enough to put together. Inherit the RichTextControl (so you can still access and format in RTF if need be) and add a couple properties and a function. There are three properties and one function I added: UseSpanTag property, UseStyleTag property, HTML property, and the function GenerateHTML.
The two functions are key to this control. The SpanTag property tells the control to format the HTML using html tags. This allows for easier formatting in line. The StyleTag property uses the HTML header to declare a format, then in the body, use the formatting on text.
The HTML property does the exact same thing (it calls the GenerateHTML function) and returns the HTML text. Simple enough.
How To Use
This control is very simple to use. You type in text normally (or enter it in programmatically) and then you can either call the function directly, as so:
Private Sub GetHtml()
Dim str As String = Me.HtmlTextBox1.GenerateHTML()
End Sub
or you can read the HTML property. Thats it, you then have an HTML formatted String object.
History
July 15, 2006 ----- Initial Version
July 26, 2006 ----- Version 2 -> Add Tag functionality and fixed a bug...see comments
September 07, 2006 ------ Version 2.1 -> Made available to VS 2003
Future Releases
I am hoping to add functionality, such as formatting individual words, not just the ForeColor, BackColor, and Font. This will come later.
Questions, Comments
Any questions or comments, feel free to e-mail me at JMMGoalster at yahoo dot com.