Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Background Highlighting with the RichTextBox the System way.

0.00/5 (No votes)
27 Apr 2003 1  
Adds support for setting the background color in the RichTextBox more directly than volking's article.

Sample Image - tarrorichtextbox.png

Introduction

This DLL extends the RichTextBox control in Windows Forms to add background highlighting color, background color clearing, highlighting and 'Scroll To Bottom' support. The article on CodeProject by Frederick Volking entitled "RichTextBox with background highlighting in VB.NET" does pretty much the same as this, only his article edits the color tables and RTF text currently used in the RichTextBox. My version uses calls on the RichTextBox directly to highlight/clear selections.

Functionality Added

A stonking 4 (count them) methods are added to the RichTextBox:

  • RichTextBox.SelectionBackColor (Property) - Gets or sets the current selection's backcolor. Used the same way as RichTextBox.SelectionColor.
  • RichTextBox.ClearBackColor (Sub) - Clears all or just the selected backcolor as though it was never there.
  • RichTextBox.Highlight (Sub) - Highlights the given text in the RichTextBox with the given color.
  • RichTextBox.ScrollToBottom (Sub) - Scrolls the RichTextBox to the bottom of the viewport.

Reusing the New RichTextBox

The release version of the dll is included in the demo project, simply reference this DLL and add the DLL to the toolbox, then drop the new RichTextBox onto a form, then you are all done.

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