So, I have a RichTextBox
(shown below) which has a monospaced font, and must have the same number of characters on each line. Doing this requires inserting a \n
newline character after every x
characters in the string that feeds the box.
I also have an algorithm that allows the cursor to move around with the press of the arrow keys, selecting individual characters as it moves. When the cursor covers a word in the box though, it should highlight the whole word.
Problem: When a word spans mutliple lines, there is an empty space following the final character of the first line, which I assume is caused by the \n
character.
How can I make the RichTextBox.Selection.Select()
not highlight these blank spaces? I can strip the selection of the character when parsing and such, but I need to be able to not highlight this blank space.
EDIT: An acceptable alternative would be making the newlines uneccessary. As in, to somehow fix the RichTextBox
so that it has always 12 characters on each line, but this is not ideal since I'd like to keep it easy to resize the window.
UPDATE: It seems that decreasing the width of the text column within the XAML has decreased the size of the highlight that goes over the edge, but has not eliminated it completely. I cannot decrease the width any more without causing text to wrap.