如何实现的WinForms RichTextBox的基本语法高亮? [英] How to implement basic syntax highlighting in Winforms RichTextBox?

查看:132
本文介绍了如何实现的WinForms 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 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

这篇关于如何实现的WinForms RichTextBox的基本语法高亮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆