ComponentOne SpellChecker for WinForms
SpellChecker for WinForms Task-Based Help / Creating a Custom Dictionary
In This Topic
    Creating a Custom Dictionary
    In This Topic

    In addition to the standard MainDictionary and UserDictionary dictionaries, C1SpellChecker also supports custom dictionaries. You can specify the custom dictionary with the CustomDictionary property.

    For example, you can create a custom dictionary that accepts as correct any words that start with 'z'; therefore, any word that starts with 'z' will be correct.

    1. From the Toolbox, add the C1SpellChecker component and RichTextBox control to your form.
      Note that the C1SpellChecker component will appear below the form, not on it.
    2. Select the RichTextBox, and set the following properties:
      • Dock property to Fill.
      • SpellChecking on C1SpellChecker1 property to True.
    3. To specify the custom dictionary, add the following code:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Private _customDict As New MySpellDictionary()
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        C1SpellChecker1.CustomDictionary = _customDict
    End Sub
    Public Class MySpellDictionary
        Implements C1.Win.C1SpellChecker.ISpellDictionary
        Public Function Contains(ByVal word As String) As Boolean Implements C1.Win.C1SpellChecker.ISpellDictionary.Contains
            Return word.StartsWith("z", StringComparison.InvariantCultureIgnoreCase)
        End Function
    End Class
    

    To write code in C#

    C#
    Copy Code
    MySpellDictionary _customDict = new MySpellDictionary();
     
    private void Form1_Load(object sender, EventArgs e)
    {
        c1SpellChecker1.CustomDictionary = _customDict;
    }
    public class MySpellDictionary : C1.Win.C1SpellChecker.ISpellDictionary
    {
        public bool Contains(string word)
        {
            return word.StartsWith("z", StringComparison.InvariantCultureIgnoreCase);
        }
    }