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 TextBox
es 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:
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!