.NET Framework:突出显示RichTextBox控件中的文本颜色仅支持有限数量的颜色 [英] .NET Framework: Highlight Text Color in RichTextBox Control Only Supports a Limited Number of Colors

查看:115
本文介绍了.NET Framework:突出显示RichTextBox控件中的文本颜色仅支持有限数量的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我们注意到.NET 4.6中当前版本的RichTextBox(System.Windows.Forms)控件存在问题。 当我们在RTF中设置自定义颜色并尝试使用颜色突出显示文本时,控件不会使用所选颜色。 
极端示例是自定义淡黄色(\red255 \ green250 \ blue205)在用作文本高亮颜色时将在控件中显示为红色。 看起来控件的当前版本仅支持一组固定的颜色。 较早版本的RichTextBox
控件没有此问题。

We have noticed an issue with the current version of the RichTextBox (System.Windows.Forms) control in .NET 4.6.  When we set in RTF a custom color and try to use the color for highlighting text the control does not use the selected color.  An extreme example is custom light yellow (\red255\green250\blue205) will show in the control as red when used as a text highlight color.  It appears that the current version of the control only supports a fixed set of colors.  Older versions the RichTextBox control did not have this issue.

是否有其他人看到此问题并找到了解决方法?

Is anyone else seeing this issue and have they found a workaround?

- Keith M

- Keith M

推荐答案

您好,

对于您的问题,我在RichTextBox中突出显示文本.net框架使用浅黄色(\red255 \green250 \ blue205)。它运作良好。以下是供您参考的代码。

For your question, I highlight text in RichTextBox with .net framework using a light yellow (\red255\green250\blue205). It works well. Here is the code for your reference.

private void button1_Click(object sender, EventArgs e)
        {
            richTextBox1.Rtf = @"{\rtf1\ansi This is highlight test text.}";
            richTextBox1.Select(8, 9);
            //richTextBox1.SelectionColor = Color.Red;
            richTextBox1.SelectionColor = Color.FromArgb(255, 250, 205); //light yellow-> "highlight"       
        }

最诚挚的问候,

Wendy


这篇关于.NET Framework:突出显示RichTextBox控件中的文本颜色仅支持有限数量的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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