格式文本框如何突出文本块 [英] Rich Text Box how to highlight text block

查看:186
本文介绍了格式文本框如何突出文本块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在RTB文本的某一部分要在改变的字体样式/彩色的感不突出,但在制造一个块选择与特定颜色的感觉。这类似于Visual Studio中如何突出期间调试模式的线。

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.

我如何可以完成使用RTB这个功能或者更确切地说,是它甚至可能吗?如果这是不可能的,我想听到执行上述任务的另一种方式。

How can I accomplish this feature using RTB or rather, is it even possible? If it isn't possible, I'd like to hear another way of performing the above task.

推荐答案

我认为你正在寻找 ScintillaNET

在另一方面,如果你想自己的RTB要做到这一点,那么你可以先找到行号使用的 TextBoxBase.Lines 财产。然后...

On the other hand if you want to do this by yourself in RTB then you can do it by first finding the lineNumber using TextBoxBase.Lines property. Then ...

//Select the line from it's number
startIndex = richTextBox.GetFirstCharIndexFromLine(lineNumber);
richTextBox.Select(startIndex, length);

//Set the selected text fore and background color
richTextBox.SelectionColor = System.Drawing.Color.White;
richTextBox.SelectionBackColor= System.Drawing.Color.Blue;

这篇关于格式文本框如何突出文本块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆