How to: Use the SharedDictionaryStorage Component

  • 2 minutes to read

The following article describes how to add the SharedDictionaryStorage component to your application. The SharedDictionaryStorage allows you to use multiple dictionaries in one or more SpellChecker instances when the application forms need different dictionaries to check spelling.

  1. Drop the SharedDictionaryStorage from the Toolbox onto the main application form.


  2. Add dictionaries to the component. In the SharedDictionaryStorage's property grid, click the Dictionaries item to invoke the Collection Editor.


    You should specify the culture and paths to the dictionary and grammar files for each dictionary. If the grammar file does not contain an alphabet string, specify the path to the alphabet file. A dictionary's culture determines its encoding.


  3. You can add dictionaries to the SharedDictionaryStorage collection in code. The code sample below adds German (Hunspell) and English (ISpell) dictionaries.

    HunspellDictionary germanDictionary = new HunspellDictionary();
    germanDictionary.Culture = new System.Globalization.CultureInfo("de_DE");
    germanDictionary.DictionaryPath = "Dictionaries//Hunspell//de_DE.dic";
    germanDictionary.GrammarPath = "Dictionaries//Hunspell//de_DE.aff";
    SpellCheckerISpellDictionary englishDictionary = new SpellCheckerISpellDictionary();
    englishDictionary.Culture = new System.Globalization.CultureInfo("en_US");
    englishDictionary.DictionaryPath = "Dictionaries//ISpell//american.xlg";
    englishDictionary.GrammarPath = "Dictionaries//ISpell//english.aff";
    englishDictionary.AlphabetPath = "Dictionaries//ISpell//EnglishAlphabet.txt";

    Refer to the How to: Add Dictionaries from an Assembly Resource article for an example on how to deploy dictionaries in the application's assembly.

  4. Set the spell checker's SpellCheckerBase.UseSharedDictionaries property to true to use dictionaries from the SharedStorageDictionary component.