C# Rich text box highlight

时光总嘲笑我的痴心妄想 提交于 2019-12-11 10:00:12

问题


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.

THANK YOU for the help!


回答1:


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).

Setting HideSelection to false should cause the highlight to remain.

RichTextBox inherits this property from TextBoxBase:

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



来源:https://stackoverflow.com/questions/9848470/c-sharp-rich-text-box-highlight

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!