富文本框颜色不变

编程入门 行业动态 更新时间:2024-10-28 21:23:23
本文介绍了富文本框颜色不变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发一个应用程序,其中我必须使用行号更改RTF文本框文本的背景颜色.我已经找到行号,但是当我尝试给该行号的相应文本上色时,它不会影响那里的任何内容.我的代码如下:

Hi, I am working on one application where i have to change the background color of a Rich text Box Text using Line Number. I have found the Line Number, but when i tried to color the respective text of that line number, its not effecting any thing there. My Code is as follows:

this.RTB.Select(this.RTB.GetFirstCharIndexFromLine(lineNumber), this.RTB.Lines[lineNumber].Length); this.RTB.SelectionBackColor = Color.Red;

请给我建议这段代码有什么问题. 谢谢 Shahab Abbasi

Please, suggest me what is wrong in this code. Thanks Shahab Abbasi

推荐答案

请告诉我您的RichTextbox数据......... 就我而言,相同的代码正在工作,请参见 Please show me your RichTextbox Data............ In my case same code is working see here int lineNumber = 2; this.richTextBox1.Select(this.richTextBox1.GetFirstCharIndexFromLine(lineNumber), this.richTextBox1.Lines[lineNumber].Length); this.richTextBox1.SelectionBackColor = Color.Red;

更多推荐

富文本框颜色不变

本文发布于:2023-06-09 04:08:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/594924.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本框   颜色

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!