Click here to Skip to main content
Licence CPOL
First Posted 15 Jul 2006
Views 76,492
Downloads 128
Bookmarked 22 times

HTML Text Box Control

By | 7 Sep 2006 | Article
A control that formats text in HTML.

Sample Image - HTML_Text_box.jpg

Introduction

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 the 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 a function that I added: UseSpanTag, UseStyleTag, HTML, 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 inline. The StyleTag property uses the HTML header to declare a format, then in the body, uses 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. That's it, you now have an HTML formatted String object.

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.

History

  • July 15, 2006 - Initial version.
  • July 26, 2006 - Version 2. Added the Tag functionality and fixed a bug... See comments.
  • September 07, 2006 - Version 2.1. Made available to VS2003.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

iwdu150



United States United States

Member

I am iwdu15, a college frosh who will be majoring in Computer Science. I use VB.Net, C#, C++, J#, Java, and some C.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralI coudnt run the code Pinmemberbigshervin20:26 16 Jun '07  
GeneralRe: I coudnt run the code Pinmemberiwdu1506:47 18 Jun '07  
QuestionCan this control work backwards PinmemberJoksa3:54 19 Apr '07  
AnswerRe: Can this control work backwards Pinmemberiwdu15011:15 19 Apr '07  
AnswerRe: Can this control work backwards Pinmemberwayneamurphy11:13 19 Jul '07  
GeneralTextbox With HTML Editor Pinmembernileshmacwan7:18 7 Sep '06  
GeneralRe: Textbox With HTML Editor Pinmemberiwdu15013:16 7 Sep '06  
GeneralAn enhancement idea PinmemberAl Ortega14:02 25 Jul '06  
GeneralRe: An enhancement idea Pinmemberiwdu15014:05 25 Jul '06  
GeneralRe: An enhancement idea [modified] PinmemberAl Ortega11:39 26 Jul '06  
GeneralRe: An enhancement idea Pinmemberiwdu15016:23 26 Jul '06  
GeneralRe: An enhancement idea Pinmemberiwdu15017:07 26 Jul '06  
GeneralRe: An enhancement idea PinmemberAl Ortega13:19 27 Jul '06  
GeneralRe: An enhancement idea Pinmemberiwdu15018:17 27 Jul '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 7 Sep 2006
Article Copyright 2006 by iwdu150
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid