ComponentOne SpellChecker for WinForms
Features / Dictionaries
In This Topic
    Dictionaries
    In This Topic

    The SpellChecker control uses up to three dictionaries while checking text:

    Word Lists

    The main dictionaries are zip files with a .dct extension. The zip file may contain several word lists, each one stored as a UTF-8-encoded text file containing lists of valid words. All such entries must have a ".words" extension. For information on how to add word lists, see the Editing Dictionary File and Creating Dictionary File topics.

    Rules

    The file may also include a "rules" entry that specifies rules to apply when spell-checking text in the dictionary language. For example, the French dictionary that ships with C1SpellChecker contains the following entries:

    These tell the spell checker to ignore some common prefixes and suffixes; they are removed before the word is checked. For example:

    Prefixes and suffixes not included will be tagged as spelling errors:

    Deploying Dictionaries

    Deploying dictionaries is trivial for English applications since the English dictionary is built into the C1SpellChecker component. Other languages are available, but require deploying the appropriate dictionaries.

    The easiest way to deploy the dictionaries with your application is to add the .dct files to your project, and set the Build Action property to None and the Copy to Output Directory property to Copy if newer. This will place the .dct files in the application directory where C1SpellChecker can find them.

    When using this deployment method, make sure the main dictionary's FileName value specifies a file name without a path. This way, the component will search for the dictionary in the directory where the C1SpellChecker assembly is located.

    By default, C1SpellChecker will also localize the built-in spell dialog box automatically, based on the current culture. You can override this behavior and specify the language used in the dialog box by setting the DialogLanguage property.

    C1SpellChecker Dictionary Editor

    You can use the dictionary maintenance utility that ships with C1SpellChecker to modify the dictionaries that ship with C1SpellChecker and also to create new dictionaries. For more details on maintaining and creating dictionaries, see the Work with Dictionary Files topic.

    Create Custom Dictionary

    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, use the following 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);
        }
    }
    
    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