Where can I find a control for WinForms that will highlight source code pasted into it? I would like one that has syntax highlighting support for many different languages but if it only works with C# I would be fine with that also.
Scintilla.NET is probably what you're looking for
Just recently have found a nice control from codeproject Fast Colored TextBox for syntax highlighting.
The only issue with using Rich Text Box as highlighter is slow performance on coloring, in cases when the size of the document is big. For a medium size documents this issue can be fixed by delayed highlighting.
As Open Source alternatives, give a look to:
- dotNetFireball
- ICSharpCode.TextEditor from SharpDevelop
Add ICSharpCode.TextEditor assembly reference to a project, choose assembly and controls for Visual Studio Toolbox. After that, you can put control to the Form. Surprisingly, you will not see Property to choose syntax highlight schema. Instead of this, you have to use method SetHighlighting. String parameter sets highlighting schema from available schemas list. These schemas are embedded into the control.
How to use, change schemas and download sample, look following article
If you're willing to pay for a control, I highly recommend this one: QWhale Syntax Edit. It's got a ton of features, comes with source code, and supports a lot of languages. I use it myself for C#, VB.NET, SQL (MS & Oracle), and it's got everything that VS provides.
Check out the AvalonEdit control. There is a good article on CodeProject explaining how to use it.
Not sure if there is any out of the box non-thirdparty solution to this.
But, have you looked at Actipro SyntaxEditor component. LinqPad, the ubercool linq tool uses it for syntax highlighting and intellisense.
you can try this http://www.codeproject.com/KB/edit/SyntaxHighlighting.aspx
来源:https://stackoverflow.com/questions/1087735/a-textbox-richtextbox-that-has-syntax-highlighting-c