Search code examples
c#winformscolorsrichtextboxfixed-width

C# Back color on text in a RichTextBox Control


I've created a Windows Form App that reads in a fixed-width text file, gets the width of the columns from user input, then uses that to display the different columns on screen with different text colours. It works fine that way.

But, it doesn't work if the field is blank - which in the text files that I'm using, they sometimes are; but I still want them to be defined. So I thought the best way to do it would be to put a back color on it, like this:

http://tinypic.com/r/2ic38sm/7

But I can't find how to do it with a RichTextBox - Is it possible? And if not, is there any way I could do it in a Windows form?

Thanks in advance!


Solution

  • Isn't there a Selection.BackColor property on the richTextBox?

    Wouldn't a GridView or ListView with Details View be a better control for your problem?