WinForms SyntaxEditor Overview

The RadSyntaxEditor control works with the underlying document with the help of taggers. Taggers are used to identify spans of text and assign them a specific tag if they match a specific condition. The identification process occurs in the GetTags method which can be overridden in a custom tagger.

The matched tags are then processed by the UI layers which color the text or draw additional elements on screen.

Telerik UI for WinForms Ninja image

The Taggers is part of Telerik UI for WinForms, a professional grade UI library with 160+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.

RadSyntaxEditor with a registered CSharpTagger

WinForms RadSyntaxEditor with a registered CSharpTagger

Predefined Taggers

RadSyntaxEditor comes with a number of predefined taggers:

  • CSharpTagger: A tagger responsible for the syntax-highlighting in the C# programming language.
  • VisualBasicTagger: A tagger responsible for the syntax-highlighting in the Visual Basic programming language.
  • JavaScriptTagger: A tagger responsible for the syntax-highlighting in the JavaScript programming language.
  • XmlTagger: A tagger responsible for the syntax-highlighting in the XML programming language.
  • SqlTagger: A tagger responsible for the syntax-highlighting in the T-SQL (Transact-SQL) programming language.
  • BracketFoldingTagger: A tagger responsible for creating collapsible (folding) regions in the code. Can be used for the JavaScript language.
  • CSharpFoldingTagger: A tagger responsible for creating folding regions in C# code.
  • VisualBasicFoldingTagger: A tagger responsible for creating folding regions in Visual Basic code.
  • TextSearchHighlightTagger: A tagger which prepares collection of TextHighlightTag for all occurrences of a given search word.
  • TextSearchUnderlineTagger: A tagger which prepares collection of UnderlineTag for all occurrences of a given search word.

Register a Tagger

To be able to use these taggers in the RadSyntaxEditor control, you first need to register them in its TaggersRegistry. This registry keeps track of all the registered taggers. Through the IsTaggerRegistered method you can check whether a specific tagger is already registered.

Registering taggers

            CSharpTagger currentLanguageTagger = new Telerik.WinForms.Controls.SyntaxEditor.Tagging.Taggers.CSharpTagger(this.radSyntaxEditor1.SyntaxEditorElement);
            this.radSyntaxEditor1.TaggersRegistry.RegisterTagger(currentLanguageTagger);

            CSharpFoldingTagger foldingTagger = new Telerik.WinForms.Controls.SyntaxEditor.Taggers.CSharpFoldingTagger(this.radSyntaxEditor1.SyntaxEditorElement);
            foldingTagger.FoldingRegionDefinitions.Add(new FoldingRegionDefinition("#if", "#endif"));


Dim currentLanguageTagger As CSharpTagger = New Telerik.WinForms.Controls.SyntaxEditor.Taggers.CSharpTagger(Me.RadSyntaxEditor1.SyntaxEditorElement)
Me.RadSyntaxEditor1.TaggersRegistry.RegisterTagger(currentLanguageTagger)
Dim foldingTagger As CSharpFoldingTagger = New Telerik.WinForms.Controls.SyntaxEditor.Taggers.CSharpFoldingTagger(Me.RadSyntaxEditor1.SyntaxEditorElement)
foldingTagger.FoldingRegionDefinitions.Add(New FoldingRegionDefinition("#if", "#endif"))
RadSyntaxEditor1.TaggersRegistry.RegisterTagger(foldingTagger)


As of R2 2021 RadSyntaxEditor offers ShouldTaggersProcessEntireLines property that indicates whether the entire line should be processed by the taggers.

See Also

In this article