Skip to main content

Spell Checker Dictionaries

  • 4 minutes to read

Supported Dictionaries

The Spell Checker for WinForms supports the following dictionaries:

If no dictionary is specified and the SpellCheckerBase.Culture property is set to EN-US, the SpellChecker uses the default English dictionary. When other dictionaries are added, the default dictionary is not loaded.

The table below compares supported dictionaries:

Simple ISpell OpenOffice Hunspell Custom
Popularity Low Low High High High
Word Detection Speed Fast Fast Fast Slow Fast
Size Large Large Large Small Various
Dictionary File Format .dic, .txt .xlg, .dic .dic .dic .dic, .txt
Grammar File (.aff) Required No Yes Yes Yes No
API Reference SpellCheckerDictionary SpellCheckerISpellDictionary SpellCheckerOpenOfficeDictionary HunspellDictionary SpellCheckerCustomDictionary

Dictionaries can be shared by several SpellChecker components. You can add them to the SharedDictionaryStorage and then set SpellCheckerBase.UseSharedDictionaries to true. Refer to the How to: Use the SharedDictionaryStorage Component topic for a code sample.

Use the SpellCheckerBase.LoadOnDemand property to load the dictionary only when its required.

After each dictionary is successfully loaded, the ISpellCheckerDictionary.DictionaryLoaded event fires. You can subscribe to the SpellCheckerBase.UnhandledException event to catch problematic situations, which may happen while a dictionary is loaded and prepared for use.

For each dictionary, you should specify its Culture and Encoding properties. Complex dictionaries, such as ISpell, OpenOffice or HunSpell, require an affix file, located in the path specified by the GrammarPath property. The need for the alphabet file is due to the method used to generate suggestion lists. For more details, please refer to the SpellCheckerDictionaryBase.AlphabetPath topic.

You can find OpenOffice dictionary at the Dictionaries page of the OpenOffice.org project. Download the required dictionaries extension form the extension repository. Change file extension to zip and unzip it with any archiver. Extract the *.dic and *.aff files to a temporary folder.

Warning

Note that the OpenOffice license cannot be used for commercial projects. Please ensure the relevant license agreement permits use within your application or project.

Custom Dictionary

Add a custom dictionary to store users’ word additions. Users can add an entry from the Spelling Dialog and use the Spelling Options Dialog to edit the dictionary.

The SpellChecker overrides a custom dictionary every time users add new words or edit the word list - this file should not be set to read-only. If the dictionary is not available, ensure another process does not use it.

Add Dictionaries

Add dictionaries to the DevExpress.XtraSpellChecker.DictionaryCollection. Use the SpellCheckerBase.Dictionaries property to access the dictionary collection.

View Example

Simple

using System.Globalization;
using DevExpress.XtraSpellChecker;
//...

SpellCheckerDictionary simpleDictionary = new SpellCheckerDictionary();
simpleDictionary.AlphabetPath = "EnglishAlphabet.txt";
simpleDictionary.Culture = new CultureInfo("en-US");
simpleDictionary.DictionaryPath = "american.txt";

//Preload the dictionary to speed up the check
simpleDictionary.Load();
spellChecker1.Dictionaries.Add(simpleDictionary);

ISpell

using DevExpress.XtraSpellChecker;
using System;
using System.Globalization;

spellChecker1.Dictionaries.Clear();

SpellCheckerISpellDictionary ispellDictionaryEnglish = new SpellCheckerISpellDictionary();
ispellDictionaryEnglish.DictionaryPath = @"Dictionaries\ISpell\en_US\american.xlg";
ispellDictionaryEnglish.GrammarPath = @"Dictionaries\ISpell\en_US\english.aff";
ispellDictionaryEnglish.AlphabetPath = @"Dictionaries\EnglishAlphabet.txt";
ispellDictionaryEnglish.Culture = new CultureInfo("en-US");

//Preload the dictionary to speed up the check
ispellDictionaryEnglish.Load();
spellChecker1.Dictionaries.Add(ispellDictionaryEnglish);

Hunspell

using DevExpress.XtraSpellChecker;
using System;
using System.Globalization;

spellChecker1.Dictionaries.Clear();

HunspellDictionary hunspellDictionaryEnglish = new HunspellDictionary();
hunspellDictionaryEnglish.DictionaryPath = @"Dictionaries\Hunspell\en_US\en_US.dic";
hunspellDictionaryEnglish.GrammarPath = @"Dictionaries\Hunspell\en_US\en_US.aff";
hunspellDictionaryEnglish.Culture = new CultureInfo("en-US");

//Preload the dictionary to speed up the check
hunspellDictionaryEnglish.Load()
spellChecker1.Dictionaries.Add(hunspellDictionaryEnglish);

OpenOffice

using DevExpress.XtraSpellChecker;
using System;
using System.Globalization;

spellChecker1.Dictionaries.Clear();

SpellCheckerOpenOfficeDictionary openOfficeDictionaryEnglish = new SpellCheckerOpenOfficeDictionary();
openOfficeDictionaryEnglish.DictionaryPath = @"Dictionaries\OpenOffice\en_US\en_US.dic";
openOfficeDictionaryEnglish.GrammarPath = @"Dictionaries\OpenOffice\en_US\en_US.aff";
openOfficeDictionaryEnglish.Culture = new CultureInfo("en-US");

//Preload the dictionary to speed up the check
openOfficeDictionaryEnglish.Load();
spellChecker1.Dictionaries.Add(openOfficeDictionaryEnglish);

Custom

using DevExpress.XtraSpellChecker;
using System;
using System.Globalization;

SpellCheckerCustomDictionary customDictionary = new SpellCheckerCustomDictionary();
customDictionary.AlphabetPath = @"Dictionaries\EnglishAlphabet.txt";
customDictionary.DictionaryPath = @"Dictionaries\CustomEnglish.dic";
customDictionary.Culture = CultureInfo.InvariantCulture;

//Preload the dictionary to speed up the check
simpleDictionary.Load();
spellChecker1.Dictionaries.Add(customDictionary);
See Also