Click here to Skip to main content
6,306,412 members and growing! (17,051 online)
Email Password   helpLost your password?
Languages » VB.NET » General     Intermediate

HTML Text Box Control

By iwdu150

A control that formats text in HTML.
VB, .NET, WinXPVS.NET2003, VS2005, Dev
Posted:15 Jul 2006
Updated:7 Sep 2006
Views:63,813
Bookmarked:18 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
9 votes for this article.
Popularity: 2.04 Rating: 2.14 out of 5
3 votes, 33.3%
1
2 votes, 22.2%
2

3

4
4 votes, 44.4%
5

Sample Image - HTML_Text_box.jpg

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

iwdu150


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.
Location: United States United States

Other popular VB.NET articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 14 of 14 (Total in Forum: 14) (Refresh)FirstPrevNext
GeneralI coudnt run the code Pinmemberbigshervin21:26 16 Jun '07  
GeneralRe: I coudnt run the code Pinmemberiwdu1507:47 18 Jun '07  
GeneralCan this control work backwards PinmemberJoksa4:54 19 Apr '07  
GeneralRe: Can this control work backwards Pinmemberiwdu15012:15 19 Apr '07  
AnswerRe: Can this control work backwards Pinmemberwayneamurphy12:13 19 Jul '07  
GeneralTextbox With HTML Editor Pinmembernileshmacwan8:18 7 Sep '06  
GeneralRe: Textbox With HTML Editor Pinmemberiwdu15014:16 7 Sep '06  
GeneralAn enhancement idea PinmemberAl Ortega15:02 25 Jul '06  
GeneralRe: An enhancement idea Pinmemberiwdu15015:05 25 Jul '06  
GeneralRe: An enhancement idea [modified] PinmemberAl Ortega12:39 26 Jul '06  
GeneralRe: An enhancement idea Pinmemberiwdu15017:23 26 Jul '06  
GeneralRe: An enhancement idea Pinmemberiwdu15018:07 26 Jul '06  
GeneralRe: An enhancement idea PinmemberAl Ortega14:19 27 Jul '06  
GeneralRe: An enhancement idea Pinmemberiwdu15019:17 27 Jul '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 7 Sep 2006
Editor:
Copyright 2006 by iwdu150
Everything else Copyright © CodeProject, 1999-2009
Web20 | Advertise on the Code Project