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

How to: Switch Between Languages

  • 2 minutes to read

When the dictionary is created and added to the spell checker dictionaries collection, its language is indicated by the DictionaryBase.Culture property. When you need to change the language to be checked, you should change the SpellCheckerBase.Culture of the XtraSpellChecker instance.

For example, when you have to spell check a section of French text, you may use the following code to switch the languages.

using System.Globalization;
//...

Boolean hasDictionary = false;

// First we create a CultureInfo object corresponding to the selected language
CultureInfo culture_info = new CultureInfo("fr-FR");

// Make sure that the spell checker component has a dictionary of the specified culture
foreach (SpellCheckerDictionaryBase dict in spellChecker1.Dictionaries) {
    if (dict.Culture.Equals(culture_info))  hasDictionary = true;
}

// If the dictionary exists we can safely change the XtraSpellChecker culture
if (hasDictionary) spellChecker1.Culture = culture_info;