RichTextBox for WPF | ComponentOne
C1RichTextBox Task-Based Help / Adding Spell Checking
In This Topic
    Adding Spell Checking
    In This Topic

    In this topic you'll add spell-checking to your application. This topic assumes you have added a C1RichTextBox control and a C1RichTextBoxToolbar control to your page and linked the two together. 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:        
      Visual Basic
      Copy Code
      Imports C1.WPF.RichTextBox
      Imports C1.WPF.SpellChecker
      
      C#
      Copy Code
      using C1.WPF.RichTextBox;
      using C1.WPF.SpellChecker;
      
    3. Add code to the MainPage constructor so that it appears similar to the following:        
      Visual Basic
      Copy Code
      Public Sub New()
          InitializeComponent()
          Dim spell As New C1SpellChecker()
          spell.MainDictionary.LoadAsync("C1Spell_en-US.dct")
          Me.C1RichTextBox.SpellChecker = spell
      End Sub
      
      C#
      Copy Code
      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.