# Adding Spell Checking

## Content



In this topic you'll add spell-checking to your application. This topic assumes you have added a [C1RichTextBox](/componentone/api/wpf/online-richtextbox/dotnet-api/C1.WPF.RichTextBox/C1.WPF.RichTextBox.C1RichTextBox.html) control and a [C1RichTextBoxToolbar](/componentone/api/wpf/online-richtextbox/dotnet-framework-api/C1.WPF.RichTextBox.Toolbar.4.6.2/C1.WPF.RichTextBox.C1RichTextBoxToolbar.html) control to your page and [linked the two together](/componentone/docs/wpf/online-richtextbox/C1RichTextBox_Task-Based_Help/Connecting_a_C1RichTextBoxToolbar_to_a_C1RichTextBox). If you currently click the **Spell Check** button in the toolbar at run time, you'll receive a message that spell checking is currently not set up. In this step you'll add a dictionary and set up spell-checking.

Complete the following steps:

1.  In the Solution Explorer, right-click the **.Web** project and select **Add | Existing Item**. The **Add Existing Item** dialog box will appear.
2.  In the **Add Existing Item** dialog box locate the **C1Spell\_en-US.dct** file included in the **RichTextBoxSamples** sample folder. By default, you can access the samples folder through the following path :

**Documents\\ComponentOne Samples\\WPF**.

This is a US English dictionary file – if you add another file, instead, you can adapt the steps below with the appropriate code.

1.  In the Solution Explorer, right-click the **MainPage.xaml** file and select **View Code** to open the code file.
2.  In the Code Editor, add the following code to import the following namespaces:
    
    ```vbnet
    Imports C1.WPF.RichTextBox
    Imports C1.WPF.SpellChecker
    ```
    
    ```csharp
    using C1.WPF.RichTextBox;
    using C1.WPF.SpellChecker;
    ```
    
3.  Add code to the **MainPage** constructor so that it appears similar to the following:
    
    ```vbnet
    Public Sub New()
        InitializeComponent()
        Dim spell As New C1SpellChecker()
        spell.MainDictionary.LoadAsync("C1Spell_en-US.dct")
        Me.C1RichTextBox.SpellChecker = spell
    End Sub
    ```
    
    ```csharp
    public MainPage()
    {
        InitializeComponent();
        var spell = new C1SpellChecker();
        spell.MainDictionary.LoadAsync("C1Spell_en-US.dct");
        this.c1RichTextBox.SpellChecker = spell;
    }
    ```
    
    This code adds spell-checking – including as-you-type spell-checking – to the application.
    

**What You've Accomplished**

In this step you added spell-checking to your **C1RichTextBox** application. Type in the **C1RichTextBox** and notice that as-you-type spell-checking is initialized and misspelled words appear with a red line underneath. If you click the **Spell Check** button in the **C1RichTextBoxToolbar**, notice that the **Spelling** dialog box now appears.