Skip to main content
A newer version of this page is available. .

SubDocument.ApplySyntaxHighlight(List<SyntaxHighlightToken>) Method

Performs a batch update of text formatting for document ranges corresponding to specified tokens.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v18.2.Core.dll

Declaration

void ApplySyntaxHighlight(
    List<SyntaxHighlightToken> tokens
)

Parameters

Name Type Description
tokens List<SyntaxHighlightToken>

A List<T><SyntaxHighlightToken,> collection containing tokens to apply, ordered by the SyntaxHighlightToken.Start value.

Remarks

Tokens are the SyntaxHighlightToken objects. They can be created manually or by using different text and code parsers, such as DevExpress code parsers available from the DevExpress.CodeParser library. The CodeParser library is contained within the DevExpress.CodeParser.v18.2.dll. You can use the DevExpress.CodeParser.CSharp.CSharpTokensHelper.GetTokens method to obtain a collection of tokens for C# code and the DevExpress.CodeParser.VB.VBTokensHelper.GetTokens method for VB code.

Note

If you use your own methods to create a token collection, make sure that it is sorted by the SyntaxHighlightToken.Start value. The GetTokens methods mentioned above return a collection of tokens already ordered by a location within the document, so no additional sorting is required.

The ISyntaxHighlightService interface can be used to execute the ApplySyntaxHighlight method when the document content is modified.

Tip

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E2993.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ApplySyntaxHighlight(List<SyntaxHighlightToken>) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also