Skip to content

Latest commit

 

History

History
40 lines (25 loc) · 3.56 KB

File metadata and controls

40 lines (25 loc) · 3.56 KB

Rich Text Editor for WinForms - How to Use Tokens to Implement T-SQL Language Syntax Highlight

The RichEditControl allows you to create a custom ISyntaxHighlightService implementation to display text in different colors and fonts according to the category of syntax sub-elements. These include keywords, comments, control-flow statements, variables, and other elements. This example describes how to highlight the T-SQL syntax. Note that we do not use the DevExpress.CodeParser library in this example.

Implementation Details

  • Create a ISyntaxHighlightService implementation.

  • Search for keywords or specific symbols and convert them into tokens. Check whether the tokens intersect. If not, add them to the token collection.

  • Specify a token’s format options in the SyntaxHighlightToken object constructor.

  • Convert the remaining text into tokens and add them to the collection. Sort the collection by their position in the text.

    Tip: We recommend that you use the GetAsFrozen method to improve performance during syntax highlight.

  • Call SubDocument.ApplySyntaxHighlight within the ISyntaxHighlightService.Execute method to enable syntax highlighting.

  • Register the created implementation in the main class.

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)