Click here to Skip to main content
13,596,895 members
Click here to Skip to main content
Add your own
alternative version


80 bookmarked
Posted 8 Mar 2007


, 25 Mar 2007
Rate this:
Please Sign up or sign in to vote.
This article describes ColorTextBox, a customizable User Control which was written completely from scratch and is intended to fill the gap between the TextBox and RichTextBox controls found in the .NET 2.0 library.

Screenshot - colortextbox_pic.png


ColorTextBox is a .NET 2.0 User Control which was written from scratch and is meant as a replacement for the TextBox control of the .NET class library.


ColorTextBox is a by-product of LMX-Editor, an Open Source XML editor I developed as part of my diploma thesis. Since I was very disappointed by the performance of the RichTextBox control available in the .NET library (the standard TextBox does not support colored text), I decided to write my own ColorTextBox on which the aforementioned editor is based.

Using the code

Although ColorTextBox does not inherit from the abstract TextBoxBase class of the .NET library, it was designed to be compatible with the default TextBox implementation. So, if you're familiar with the usage of the standard TextBox, you can use ColorTextBox right away.

In fact, it should be no or little effort to replace TextBoxes in existing applications with instances of the ColorTextBox. If you develop under Visual Studio .NET 2005, you can use the Forms Designer to configure all relevant properties of the control.

Just look at the code provided in the example: it's a simple text editor which was built in about 30 minutes, and shows the most important features of the ColorTextBox.

Points of interest

As mentioned before, the ColorTextBox control is the base for an Open Source XML editor I wrote, which includes features like syntax highlighting and folding. If you want to write your own code editing component, have a look at the complete source code at SourceForge, which contains a generic CodeTextBox control which can be easily extended to support the mentioned features. Furthermore, the latest code for ColorTextBox will always be available under the link above!


03-08-07 Version 1.0.0:

  • Initial release
03-12-07 Version 1.0.1:
  • Added various keystroke shortcuts
  • Support for arbitrary input chars
03-25-07 Version 1.1.0:
  • Various bugfixes (Color support, Rendering, Scrolling, ...)
  • Added support for additional shortcut keys (similar to TextPad)
  • Added properties to improve compatability with the TextBox class
  • Added new demo application to demonstrate the most important features
  • Note: Some interfaces had to be changed!


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

Austria Austria
No Biography provided

You may also be interested in...

Comments and Discussions

Suggestionwhat if not multi-line? Pin
John Torjo8-Nov-15 19:56
professionalJohn Torjo8-Nov-15 19:56 
QuestionRead Only without cursor ? Pin
Wrangly6-Nov-13 2:51
memberWrangly6-Nov-13 2:51 
QuestionWhy not TextBoxBase? Pin
i0013-Nov-11 17:12
memberi0013-Nov-11 17:12 
GeneralMy vote of 5 Pin
Preky1-May-11 12:12
memberPreky1-May-11 12:12 
Generalselect(int, int) Pin
Member 30574962-Jan-08 1:15
memberMember 30574962-Jan-08 1:15 
General.SelectionBackColor property isn't in sync w/ rich text boxes Pin
cipher_nemo1-Nov-07 9:23
membercipher_nemo1-Nov-07 9:23 
GeneralRe: .SelectionBackColor property isn't in sync w/ rich text boxes Pin
Chrisi4762-Nov-07 9:36
memberChrisi4762-Nov-07 9:36 
QuestionNot working with KeyUp and KeyDown events? Pin
cipher_nemo28-Oct-07 10:28
membercipher_nemo28-Oct-07 10:28 
AnswerRe: Not working with KeyUp and KeyDown events? Pin
cipher_nemo29-Oct-07 7:03
membercipher_nemo29-Oct-07 7:03 
GeneralRe: Not working with KeyUp and KeyDown events? Pin
Chrisi4762-Nov-07 9:26
memberChrisi4762-Nov-07 9:26 
GeneralFont anti-alias (ie: font smoothing, ClearType, etc.) Pin
cipher_nemo28-Oct-07 7:40
membercipher_nemo28-Oct-07 7:40 
GeneralRe: Font anti-alias (ie: font smoothing, ClearType, etc.) Pin
Chrisi4762-Nov-07 9:22
memberChrisi4762-Nov-07 9:22 
GeneralRe: Font anti-alias (ie: font smoothing, ClearType, etc.) Pin
cipher_nemo12-Nov-07 4:31
membercipher_nemo12-Nov-07 4:31 
GeneralRe: Font anti-alias (ie: font smoothing, ClearType, etc.) Pin
Aki99911-Sep-08 1:53
memberAki99911-Sep-08 1:53 
GeneralRe: Font anti-alias (ie: font smoothing, ClearType, etc.) Pin
Cor Hoender18-Feb-09 22:42
memberCor Hoender18-Feb-09 22:42 
Generalhi Pin
balakpn30-Apr-07 3:57
memberbalakpn30-Apr-07 3:57 
GeneralRe: hi Pin
Chrisi4767-May-07 1:34
memberChrisi4767-May-07 1:34 
GeneralRe: hi Pin
cipher_nemo28-Oct-07 7:04
membercipher_nemo28-Oct-07 7:04 
GeneralFont Property doesn't work ... Pin
ODanny17-Apr-07 2:39
memberODanny17-Apr-07 2:39 
GeneralRe: Font Property doesn't work ... Pin
Chrisi47617-Apr-07 21:05
memberChrisi47617-Apr-07 21:05 
GeneralRe: Font Property doesn't work ... Pin
ODanny17-Apr-07 21:18
memberODanny17-Apr-07 21:18 
QuestionPassword? Pin
nightrider131-Apr-07 11:27
membernightrider131-Apr-07 11:27 
AnswerRe: Password? Pin
Chrisi4762-Apr-07 5:04
memberChrisi4762-Apr-07 5:04 
GeneralRe: Password? Pin
nightrider133-Apr-07 0:48
membernightrider133-Apr-07 0:48 
GeneralRich Text Pin
mo_kondori25-Mar-07 20:56
membermo_kondori25-Mar-07 20:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Cookies | Terms of Use | Mobile
Web02-2016 | 2.8.180621.3 | Last Updated 25 Mar 2007
Article Copyright 2007 by Chrisi476
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid