本文介绍了删除富文本框 SelectionBackColor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将富文本框的 SelectionBackColor 更改为无颜色"?

How can I change SelectionBackColor of richtext box to "no color"?

我试过这些:

Color.FromArgb(0, 255, 255, 255);
Color.Empty;
Color.White;
Color.Transparent;

但它们都返回相同的结果:Color.White !!!

But they are all return same result: Color.White !!!

更多的描述,把richtextbox的背景色改成粉红色,然后把SelectionBackColor改成红色,现在,试着去掉SelectionBackColor,你会看到颜色是白色的.请注意,在此示例中将 SelectionBackColor 更改为粉红色是不正确的 :D !!!

For more description, change richtextbox backcolor to some color like pink, then change SelectionBackColor to red, now, try to remove SelectionBackColor, you see that the color will be white. please note that it is not true to change SelectionBackColor to pink in this example :D !!!

推荐答案

可能有点晚了,但我注意到如果你写了

Maybe a bit late, but i just noticed if you write

this.richTextBox.SelectedText = "\r";

RTF 丢失了以下文本的所有格式,包括 SelectionBackColor.

the RTF loses all formatting for the following texts, including the SelectionBackColor.

例如

this.richTextBox.SelectionBackColor = Color.Yellow;
this.richTextBox.SelectedText = "the damn yellow backcolor is set";
this.richTextBox.SelectedText = "\r";
this.richTextBox.SelectedText = "now i have transparent backcolor again and the default text";

这篇关于删除富文本框 SelectionBackColor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-01 02:34