Click here to Skip to main content
Click here to Skip to main content

ColorTextBox

, 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

Introduction

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.

Background

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!

History

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!

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

Chrisi476

Austria Austria
No Biography provided

Comments and Discussions

 
QuestionRead Only without cursor ? PinmemberWrangly6-Nov-13 2:51 
QuestionWhy not TextBoxBase? Pinmemberi0013-Nov-11 17:12 
GeneralMy vote of 5 PinmemberPreky1-May-11 12:12 
Generalselect(int, int) PinmemberMember 30574962-Jan-08 1:15 
General.SelectionBackColor property isn't in sync w/ rich text boxes Pinmembercipher_nemo1-Nov-07 9:23 
GeneralRe: .SelectionBackColor property isn't in sync w/ rich text boxes PinmemberChrisi4762-Nov-07 9:36 
QuestionNot working with KeyUp and KeyDown events? Pinmembercipher_nemo28-Oct-07 10:28 
AnswerRe: Not working with KeyUp and KeyDown events? Pinmembercipher_nemo29-Oct-07 7:03 
GeneralRe: Not working with KeyUp and KeyDown events? PinmemberChrisi4762-Nov-07 9:26 
GeneralFont anti-alias (ie: font smoothing, ClearType, etc.) Pinmembercipher_nemo28-Oct-07 7:40 
GeneralRe: Font anti-alias (ie: font smoothing, ClearType, etc.) PinmemberChrisi4762-Nov-07 9:22 
GeneralRe: Font anti-alias (ie: font smoothing, ClearType, etc.) Pinmembercipher_nemo12-Nov-07 4:31 
GeneralRe: Font anti-alias (ie: font smoothing, ClearType, etc.) PinmemberAki99911-Sep-08 1:53 
GeneralRe: Font anti-alias (ie: font smoothing, ClearType, etc.) PinmemberCor Hoender18-Feb-09 22:42 
Generalhi Pinmemberbalakpn30-Apr-07 3:57 
GeneralRe: hi PinmemberChrisi4767-May-07 1:34 
GeneralRe: hi Pinmembercipher_nemo28-Oct-07 7:04 
GeneralFont Property doesn't work ... PinmemberODanny17-Apr-07 2:39 
GeneralRe: Font Property doesn't work ... PinmemberChrisi47617-Apr-07 21:05 
GeneralRe: Font Property doesn't work ... PinmemberODanny17-Apr-07 21:18 
QuestionPassword? Pinmembernightrider131-Apr-07 11:27 
AnswerRe: Password? PinmemberChrisi4762-Apr-07 5:04 
GeneralRe: Password? Pinmembernightrider133-Apr-07 0:48 
GeneralRich Text Pinmembermo_kondori25-Mar-07 20:56 
GeneralRe: Rich Text PinmemberChrisi47626-Mar-07 2:07 

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.

| Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 25 Mar 2007
Article Copyright 2007 by Chrisi476
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid