Rectangular BackColor of selection in RichTextBox

Posted by AgentConundrum on Stack Overflow See other posts from Stack Overflow or by AgentConundrum
Published on 2009-09-08T21:57:59Z Indexed on 2010/05/02 20:08 UTC
Read the original article Hit count: 266

Filed under:
|
|
|

Background:
I'm going to start studying/coding at the local university's library. Since I'm not a student, I won't be able to utilize their wireless internet access. Since StackOverflow is such a great resource, I want to be able to take it with me, so I'm building a small desktop application to load/search/display the most recent data dumps.

Problem:
I want to display code blocks in the same sort of rectangular block as this site does, so I played with the RichTextBox control to try to create this effect. Unfortunately, the RichTextBox.SelectedBackColor property only colors the actual text, when what I want is a rectangle reaching to the outer limits of the selection.

Example:
This is what I am able to produce with the RichTextBox:

This is what I would like to create:

Questions:

  • Is there any way to produce this effect using the RichTextBox?
  • If not, are there any other controls I could use to create this effect?

© Stack Overflow or respective owner

Related posts about c#

Related posts about richtextbox