Skip to main content
A newer version of this page is available. .

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.

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.

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