I need a certain portion of my text in RTB to be highlighted not in the sense of changing the font style/color, but in the sense of making a block selection with a particular color. This is similar to how Visual Studio highlights a line during debug mode.
The important thing here is to achieve the mentioned feature WITHOUT using richtextbox.select function, because the richtextbox I have is being periodically updated and if it calls the select function on each update, the user will have a difficult time dragging the text and I don’t want that to happen.
I’ve heard a solution somewhere along the line of editing the rtf but I’m not entirely certain how to do this. I’d appreciate any help given.
EDIT: Just realized question is for winforms. The following answer is for WPF, rather than delete I’m gonna leave it, in case someone find it useful.
Get the text using TextRange(…) and apply Background
for example:
But perhaps you should look into your update mechanism and come up with a better solution.