如何实现的WinForms RichTextBox的基本语法高亮?如何实现、语法、基本、RichTextBox

由网友(谢谢你的爱▲)分享简介:我的话,我想强调我的的RichTextBox 控制列表,我就怎么做,但具有解析一切独立的话有问题的想法I have a list of words I want to highlight in my RichTextBox control, I have an idea on how to do it but hav...

我的话,我想强调我的的RichTextBox 控制列表,我就怎么做,但具有解析一切独立的话有问题的想法

I have a list of words I want to highlight in my RichTextBox control, I have an idea on how to do it but having a problem with parsing everything to separate words.

我如何解析行或整个文本转换成单独的单词,然后列举了他们,并用它们上色 RichTextBox.Select()方法。

How can I parse a line or the whole text into separate words and then enumerate over them and color them using RichTextBox.Select() method.

这是一个很好的方式?有没有更好/更快的方式?

Is this a good way? Is there a better/faster way?

推荐答案

使用的RichTextBox.Find(字符串,的Int32,的Int32,RichTextBoxFinds)方法来查找控制你的字符串。然后,您可以通过更改起点到该点的当前单词后循环。

Use the RichTextBox.Find(String, Int32, Int32, RichTextBoxFinds) method to find your strings in the control. You can then iterate by changing the Start point to the point after the current word.

不知道这个方案的性能,但它会工作。

Not sure on the performance of this scheme but it will work.

http://msdn.microsoft.com/en-us/library/ yab8wkhy.aspx

阅读全文

相关推荐

最新文章