简体   繁体   中英

Coloring backgorund of richtextbox line in C#


I'm trying to color a specific line's background in a RichTextBox.
I need the line's background to be colored all the way to the end of the right side of the control.
I tried using the SelectionBackColor property, but it colors only until the end of the line.
Does anybody know of a way to do this?
thanks :)

嗯,我相信您必须做一些自定义绘画才能做到这一点,因为正如您所说,使用RTF格式可以格式化文本,因此,如果没有文本(字符,空格或制表符...),则无法访问控件的这些部分除非您确实更改了整个控件的背景颜色,否则它们是完全空白的...

Bit messy, but if you don't want to go ahead with custom painting the control. You could make the textbox transparent, then add an image behind the control which has the line selected. You could then change the Image.Location.Y value on the TextChanged event.

Customizing the stock Windows rich text control is possible, but they didn't make it easy. If I were you, I would do what I did: Purchase a better text control .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM