Skip to content

DevExpress-Examples/how-to-implement-t-sql-language-syntax-highlighting-by-creating-syntax-highlight-tokens-e4139

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

Create a custom ISyntaxHighlightService implementation to highlight the T-SQL syntax.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published