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 SpellChecker.Culture property.
For example, when you have to spell check a section of French text, you may use the following code to switch the languages.
using DevExpress.XtraSpellChecker;
using System.Globalization;
//...
public partial class Form1 : RibbonForm
{
Boolean hasDictionary = false;
CultureInfo culture_info;
public Form1() {
// First we create a CultureInfo object corresponding to the selected language
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;
}
}
private void switchCultureBtn_ItemClick(object sender, ItemClickEventArgs e)
{
// If the dictionary exists we can safely change the XtraSpellChecker culture
if (hasDictionary) spellChecker1.Culture = culture_info;
}
}