# Getting Started with WinForms SyntaxEditor

This tutorial will help you to quickly get started using the control.

## Adding Telerik Assemblies Using NuGet

To use `RadSyntaxEditor` when working with NuGet packages, install the `Telerik.UI.for.WinForms.AllControls` package. The [package target framework version may vary](https://www.telerik.com/products/winforms/documentation/visual-studio-integration/available-nugets).

If you don’t need all controls, you can instead install a more lightweight package targeting only RadSyntaxEditor: **UI.for.WinForms.SyntaxEditor**. This package has a dependency on **UI.for.WinForms.Common**, which will be automatically installed when adding the **SyntaxEditor NuGet**.

Read more about NuGet installation in the [Install using NuGet Packages](https://www.telerik.com/products/winforms/documentation/installation-and-upgrades/install-using-nuget) article.

> tip With the 2025 Q1 release, the Telerik UI for WinForms has a new licensing mechanism. You can learn more about it [here](https://www.telerik.com/products/winforms/documentation/licensing/license-key).

## Adding Assembly References Manually

When dragging and dropping a control from the Visual Studio (VS) Toolbox onto the Form Designer, VS automatically adds the necessary assemblies. However, if you're adding the control programmatically, you'll need to manually reference the following assemblies:

* **Telerik.Licensing.Runtime**
* **Telerik.WinControls**
* **Telerik.WinControls.SyntaxEditor**
* **Telerik.WinControls.UI**
* **TelerikCommon**

The Telerik UI for WinForms assemblies can be install by using one of the available [installation approaches](https://www.telerik.com/products/winforms/documentation/installation-and-upgrades/installing-on-your-computer).

## Defining RadSyntaxEditor

To start using the control you only need to add a **RadSyntaxEditor** to the form either at design time by dragging it from the Toolbox and dropping it into the form or at run time via code.

#### Adding a RadSyntaxEditor at run time

```C#
RadSyntaxEditor radSyntaxEditor1 = new RadSyntaxEditor();

```

```VB.NET
Dim radSyntaxEditor1 As RadSyntaxEditor = New RadSyntaxEditor()

```

#### Figure 1: Empty RadSyntaxEditor

![WinForms RadSyntaxEditor Empty](https://www.telerik.com/products/winforms/documentation/assets/ee7446fd4363d481c718835aca574171/getting-started001.png)

## Opening a File

To load a file in the **RadSyntaxEditor** you need to use its **Document** property.

```C#
using (StreamReader reader = new StreamReader(@"..\..\SyntaxEditor\CS.File.txt"))
{
    radSyntaxEditor1.Document = new TextDocument(reader);
}
```

```VB.NET
Using reader As StreamReader = New StreamReader("..\..\SyntaxEditor\CS_File.txt")
    RadSyntaxEditor1.Document = New TextDocument(reader)
End Using
```

#### Figure 2: RadSyntaxEditor with a loaded C# file

![WinForms RadSyntaxEditor with a Loaded CSharp File](https://www.telerik.com/products/winforms/documentation/assets/2943f92cfd179e67296777bba40ee246/getting-started002.png)

## Enable Syntax Highlighting

Once you have loaded the code, you need to register an appropriate tagger to enable syntax highlighting for the particular language.

```C#
CSharpTagger cSharptagger = new CSharpTagger(this.radSyntaxEditor1.SyntaxEditorElement);
this.radSyntaxEditor1.TaggersRegistry.RegisterTagger(cSharptagger);
```

```VB.NET
Dim cSharptagger As CSharpTagger = New CSharpTagger(Me.RadSyntaxEditor1.SyntaxEditorElement)
Me.RadSyntaxEditor1.TaggersRegistry.RegisterTagger(cSharptagger)
```

#### Figure 3: RadSyntaxEditor with C# code highlighting

![WinForms RadSyntaxEditor with CSharp Code Highlighting](https://www.telerik.com/products/winforms/documentation/assets/e9a447a1fabe75e61e6092cd79362355/getting-started003.png)

## Telerik UI for WinForms Learning Resources

* [Telerik UI for WinForms SyntaxEditor Component](https://www.telerik.com/products/winforms/syntax-editor.aspx)
* [Getting Started with Telerik UI for WinForms Components](https://docs.telerik.com/devtools/winforms/getting-started/first-steps)
* [Telerik UI for WinForms Setup](https://docs.telerik.com/devtools/winforms/installation-and-upgrades/installing-on-your-computer)
* [Telerik UI for WinForms Converter](https://www.telerik.com/products/winforms/documentation/ai-coding-assistant/converter/converter)
* [Telerik UI for WinForms Visual Studio Templates](https://docs.telerik.com/devtools/winforms/visual-studio-integration/visual-studio-templates)
* [Deploy Telerik UI for WinForms Applications](https://docs.telerik.com/devtools/winforms/deployment-and-distribution/application-deployment)
* [Telerik UI for WinForms Virtual Classroom(Training Courses for Registered Users)](https://learn.telerik.com/learn/course/external/view/elearning/17/telerik-ui-for-winforms)
* [Telerik UI for WinForms License Agreement)](https://www.telerik.com/purchase/license-agreement/winforms-dlw-s)
