Click here to Skip to main content
15,880,608 members
Articles / Desktop Programming / Windows Forms
Article

ColorTextBox

Rate me:
Please Sign up or sign in to vote.
4.93/5 (14 votes)
25 Mar 2007Apache2 min read 148.6K   3.4K   81   50
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, along with any associated source code and files, is licensed under The Apache License, Version 2.0


Written By
Austria Austria
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRe: It's fast! but please fix the bugs Pin
Chrisi47617-Mar-07 5:26
Chrisi47617-Mar-07 5:26 
GeneralRe: It's fast! but please fix the bugs Pin
Sergey Alexandrovich Kryukov19-Mar-07 11:10
mvaSergey Alexandrovich Kryukov19-Mar-07 11:10 
GeneralRe: It's fast! but please fix the bugs Pin
Chrisi47621-Mar-07 8:30
Chrisi47621-Mar-07 8:30 
GeneralCannot enter Polish letters. Pin
vanad.min13-Mar-07 9:35
vanad.min13-Mar-07 9:35 
GeneralRe: Cannot enter Polish letters. Pin
Chrisi47614-Mar-07 13:11
Chrisi47614-Mar-07 13:11 
QuestionWordwrap? Pin
Quentin Pouplard8-Mar-07 23:13
Quentin Pouplard8-Mar-07 23:13 
AnswerRe: Wordwrap? Pin
Chrisi4769-Mar-07 6:14
Chrisi4769-Mar-07 6:14 
QuestionRe: Wordwrap? Pin
lalaphilippe16-Nov-11 5:46
lalaphilippe16-Nov-11 5:46 
Hello,

Thanks a lot for this control, it's working great.
Any luck for the wrapping feature? that would be so handy Smile | :)

Thanks again for your work,
Philippe
Philippe

QuestionSelect All (CTRL + A) and other Keys Shortcuts not supported (or Bug) ? Pin
Miketrix8-Mar-07 21:12
Miketrix8-Mar-07 21:12 
AnswerRe: Select All (CTRL + A) and other Keys Shortcuts not supported (or Bug) ? Pin
Chrisi4769-Mar-07 6:07
Chrisi4769-Mar-07 6:07 
GeneralRe: Select All (CTRL + A) and other Keys Shortcuts not supported (or Bug) ? Pin
emty2229-Feb-08 14:16
emty2229-Feb-08 14:16 
GeneralKey for the source code on sourceforge Pin
uniquekaiser8-Mar-07 11:01
uniquekaiser8-Mar-07 11:01 
GeneralRe: Key for the source code on sourceforge Pin
Chrisi4769-Mar-07 6:01
Chrisi4769-Mar-07 6:01 
Generalwritten from scratch Pin
Ian MacLean8-Mar-07 10:59
Ian MacLean8-Mar-07 10:59 
GeneralRe: written from scratch Pin
Chrisi4769-Mar-07 5:41
Chrisi4769-Mar-07 5:41 
Generaljunk [modified] Pin
Thanks for all the fish8-Mar-07 9:57
Thanks for all the fish8-Mar-07 9:57 
GeneralRe: junk Pin
toxcct12-Mar-07 22:06
toxcct12-Mar-07 22:06 

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.