富文本框突出显示

富文本框突出显示

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

问题描述

我有一个富文本框和一个字体对话框.问题是当我突出显示某个字符串或一组字符串然后打开对话框时,突出显示颜色消失了.尽管更改是成功的(例如,如果我更改了突出显示的字符串的字体系列,它将更改).出于审美目的,我希望保留突出显示的颜色,然后在完成更改后将其删除.

I have a rich text box and a font dialog box. The problem is that when i highlight a certain string or group of strings then open the dialog box, the highlight color disappears. Although the changes are successful (like if i change the font family of a highlighted string it changes). For aesthetic purposes i would like to retain the highlight color, then remove it whenever the changes are done.

谢谢您的帮助!

推荐答案

富文本框具有一个名为HideSelection的属性,默认情况下为true.当文本框失去焦点时(如打开字体对话框时那样),高光将消失.

The rich text box has a property called HideSelection which is true by default. That causes the highlight to disappear when the text box loses focus (as it does when you open the font dialog).

HideSelection设置为false应该会保留突出显示.

Setting HideSelection to false should cause the highlight to remain.

RichTextBox从TextBoxBase继承此属性:

RichTextBox inherits this property from TextBoxBase:

http://msdn.microsoft. com/en-us/library/system.windows.forms.textboxbase.hideselection.aspx

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

08-11 17:34