Click here to Skip to main content
15,867,986 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 147.4K   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

 
Generalselect(int, int) Pin
Member 30574962-Jan-08 1:15
Member 30574962-Jan-08 1:15 

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.