[]
The SpellChecker control uses up to three dictionaries while checking text:
Main dictionaries: Read-only dictionary that contains the main word list. The US-English version of this dictionary is built into the control, so there's no need for any additional files. Other languages are available as .dct files that ship with the control, and can be selected using the FileName property.
User dictionaries: Read-write dictionary used to store words that are correct, but are not part of the main dictionaries. These files are stored as plain UTF-8 text, and can be selected using the FileName property.
Custom dictionaries: Any .NET object that implements the ISpellDictionary interface. This allows users to create their own dictionary classes, using whatever scheme makes sense in their application. A custom dictionary could, for example, look up words on the Web using a Web service (and then cache them for speed).
The main dictionaries are zip files with a .dct extension. The zip file may contain several word lists, each one stored as a UTF-8-encoded text file containing lists of valid words. All such entries must have a ".words" extension. For information on how to add word lists, see the Editing Dictionary File and Creating Dictionary File topics.
The file may also include a "rules" entry that specifies rules to apply when spell-checking text in the dictionary language. For example, the French dictionary that ships with C1SpellChecker contains the following entries:
IgnorePrefix: l' d' j' da' m' s' n' qu'
IgnoreSuffix: 's
These tell the spell checker to ignore some common prefixes and suffixes; they are removed before the word is checked. For example:
· l'amour (check 'amour' -> correct)
· l'amuor (check 'amuor' -> incorrect)
· Maxim's (check 'Maxim' -> correct)
· Naxim's (check 'Naxim' -> incorrect)
Prefixes and suffixes not included will be tagged as spelling errors:
h'amour (check 'h'amour' -> incorrect)
x'amuor (check 'x'amuor' -> incorrect)
Deploying dictionaries is trivial for English applications since the English dictionary is built into the C1SpellChecker component. Other languages are available, but require deploying the appropriate dictionaries.
The easiest way to deploy the dictionaries with your application is to add the .dct files to your project, and set the Build Action property to None and the Copy to Output Directory property to Copy if newer. This will place the .dct files in the application directory where C1SpellChecker can find them.
When using this deployment method, make sure the main dictionary's FileName value specifies a file name without a path. This way, the component will search for the dictionary in the directory where the C1SpellChecker assembly is located.
By default, C1SpellChecker will also localize the built-in spell dialog box automatically, based on the current culture. You can override this behavior and specify the language used in the dialog box by setting the DialogLanguage property.
You can use the dictionary maintenance utility that ships with C1SpellChecker to modify the dictionaries that ship with C1SpellChecker and also to create new dictionaries. For more details on maintaining and creating dictionaries, see the Work with Dictionary Files topic.
In addition to the standard MainDictionary and UserDictionary dictionaries, C1SpellChecker also supports custom dictionaries. You can specify the custom dictionary with the CustomDictionary property.
For example, you can create a custom dictionary that accepts as correct any words that start with 'z'; therefore, any word that starts with 'z' will be correct.
From the Toolbox, add the C1SpellChecker component and RichTextBox control to your form.
Note that the C1SpellChecker component will appear below the form, not on it.
Select the RichTextBox, and set the following properties:
Dock property to Fill.
SpellChecking on C1SpellChecker1 property to True.
To specify the custom dictionary, use the following code:
MySpellDictionary _customDict = new MySpellDictionary();
private void Form1_Load(object sender, EventArgs e)
{
c1SpellChecker1.CustomDictionary = _customDict;
}
public class MySpellDictionary : C1.Win.C1SpellChecker.ISpellDictionary
{
public bool Contains(string word)
{
return word.StartsWith("z", StringComparison.InvariantCultureIgnoreCase);
}
}Private _customDict As New MySpellDictionary()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
C1SpellChecker1.CustomDictionary = _customDict
End Sub
Public Class MySpellDictionary
Implements C1.Win.C1SpellChecker.ISpellDictionary
Public Function Contains(ByVal word As String) As Boolean Implements C1.Win.C1SpellChecker.ISpellDictionary.Contains
Return word.StartsWith("z", StringComparison.InvariantCultureIgnoreCase)
End Function
End Class