语法高亮控件ICSharpCode.TextEditor来自开源项目SharpDevelop,今天才知道,汗!害我白白花费时间自己编了一个SyntaxTextBox(http://surfsky.cnblogs.com/archive/2005/12/12/295814.html)。不妨发挥拿来主义风格,解剖了它再说!科学研究发现,咳咳,这个控件比较牛了啦~。VisualStudio代码编辑器的功能基本都能实现(包括CodeComplete和tip功能),速度也很快,而且是--开源免费软件!(大家鼓掌:) ,我想我爱上它了^_^,在此严重推荐一下!
1。以下是该控件的源代码和自己草编的简单使用例程:
ICSharpCode.TextEditor1.1的源代码:【下载】
ICSharpCode.TextEditor2.2的源代码:【下载】
自己编的使用例程:【下载】
2。使用效果:

3。使用该控件的关键句子:
using
ICSharpCode.TextEditor;
using
ICSharpCode.TextEditor.Gui.CompletionWindow;
using
ICSharpCode.TextEditor.Document;
using
ICSharpCode.TextEditor.Actions;
protected
ICSharpCode.TextEditor.TextEditorControl txtContent;
txtContent.Document.HighlightingStrategy
=
HighlightingStrategyFactory.CreateHighlightingStrategy(
"
C#
"
);
txtContent.Encoding
=
System.Text.Encoding.Default;
这几句代码若是不写的话,会无法高亮显示代码且汉字会变乱码的。切记切记,阿弥陀佛~
欢迎大家讨论该控件的使用方法~~
本文介绍了一个强大的开源语法高亮控件ICSharpCode.TextEditor,该控件源自SharpDevelop项目。它几乎实现了VisualStudio代码编辑器的所有功能,如CodeComplete和提示功能,并且运行速度快。文中提供了关键代码示例及使用效果。
701






