XtraSpellChecker: A simple but powerful spell checker for WinForms applications

WinForms Team Blog
17 September 2007

You can easily provide spell checking capabilities to your WinForms applications with XtraSpellChecker.


Compatible Controls

The Spell Checker can check the spelling of almost any control that has a Text property. Some examples of supported controls:

  • System.Windows.Forms.TextBox
  • DevExpress.XtraEditors.TextEdit
  • DevExpress.XtraEditors.MemoEdit
  • System.Windows.Forms.RichTextBox (Next Release, 2007 vol 3)

The XtraSpellChecker can check with our WinForms grids (e.g. XtraGrid, XtraVerticalGrid, etc.) as well since they contain TextEdit and MemoEdit editors for their cells.

You can also check any arbitrary text by passing it to the Check method as a parameter.

Components To Use

The main component, which provides all spell checking abilities, is the SpellChecker. The clip_image001SpellChecker is located in the “DX: Win.v7.2” tab in the Visual Studio toolbox. You can also create it at runtime:

using DevExpress.XtraSpellChecker;

SpellChecker spellChecker1 = new SpellChecker();

You can now set some it's properties like the default for Culture property. This specifies culture settings (the symbols encoding, language and phonetic specifics):

spellChecker1.Culture = new System.Globalization.CultureInfo("en-US");

Please note that if you use several SpellChecker components and one dictionary, then a clip_image002SharedDictionaryStorage component is required.

Enable Spell Checking

The SpellChecker component provides two methods to check the spelling for controls: Check() and CheckContainer().

The following code demonstrates how to pass a text to the Check method:

private void simpleButton1_Click(object sender, EventArgs e) { 
   textBox1.Text = spellChecker1.Check(textBox1.Text);

The Dictionaries

The SpellChecker component uses special spell checking algorithms. Every algorithm requires a dictionary, which provides the list of words and/or rules to generate this list. To enable spell checking in your application you need to define at least one dictionary.

First choose which dictionary best meets your requirements. The XtraSpellChecker suite supports four basic dictionary types.

  • Simple
  • ISpell
  • Open Office
  • Custom

Dictionaries can be defined both at design and runtime. For example, at runtime you can create an ISpell dictionary:

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

You'll see each of these dictionaries described in more detail in an upcoming post.

Download and try the XtraSpellChecker today. The XtraSpellChecker Suite is part of the DXperience Professional and Enterprise Suites. Currently, the XtraSpellChecker Suite is for Windows Forms only. However, an ASP .NET version is being developed.

Are you using the XtraSpellChecker in your apps? I'd love to hear your stories with this amazing little control.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.