本文介绍了如果有超过2个空格,如何突出显示富文本框WPF控件的部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个richtextbox控件在我的WPF 4.0应用程序。现在假设我有一个像

I have a richtextbox control in my WPF 4.0 application. Now suppose I have a text like

hello how [space] [space] ru?[space] [space]

"hello how [space][space] r u? [space][space] I am fine"

可以注意到 how和r 之间以及之间有两个间隔?和

As can be noticed that there are two gaps between how and r as well as between ? and I.

当这种情况发生时,部分将以绿色突出显示。 如何..r和从?到我将用绿色加亮显示。

When this will happen then the portion will be highlighted with green e.g. how ..r and from ? to I will be highlighted with green color.

如果两个单词之间的空格大于2,那么它将用绿色突出显示。

i.e. if the space between two words are more than 2 then that will be highlighted with green.

是否可以在WPF RichTextbox控件中做?如果是这样,请帮助我写这样。到现在我已经做了,我只能找出两个单词之间的距离。

Is it possible to do in WPF RichTextbox control? If so, please help me in writing so. As of now what I have done is that I have only able to find out the distance of spaces between two words.

注意:〜[Space]表示空格。

Note:~ [Space] means the white spaces. Since the gap was not prominent(as it was not coming in the editor), that's the reason I made it like so.

感谢

WPF4.0 / C#4.0

WPF4.0/ C#4.0

推荐答案

这里是一个渐进的场景,RichTextBox突出显示多个范围,它可能会导致你在右边路径。

Here is a progressive scenario featuring RichTextBox highlighting multiple ranges, it may lead you on the right path.

他最终得到它的工作,但你必须修改它以识别空白空间。

He ends up getting it to work, but you will have to modify it to recognize white space perhaps.

这篇关于如果有超过2个空格,如何突出显示富文本框WPF控件的部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 09:48