Use the AutoReplaceList property to spell-check a list of words, and if a match is found on the list then the misspelled word is replaced with the corresponding list entry as-you-type.
For example, you can monitor spelling on a Windows.Forms.RichTextBox control using this list. To see this feature in action, complete the following steps:
Note that the C1SpellChecker component will appear below the form, not on it.
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Imports C1.Win.C1SpellChecker |
To write code in C#
C# |
Copy Code
|
---|---|
using C1.Win.C1SpellChecker; |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
' build AutoReplace list C1SpellChecker1.AutoReplaceList.Clear() C1SpellChecker1.AutoReplaceList.Add("becuase", "because") C1SpellChecker1.AutoReplaceList.Add("cant", "can't") C1SpellChecker1.AutoReplaceList.Add("recieve", "receive") C1SpellChecker1.AutoReplaceList.Add("teh", "the") C1SpellChecker1.AutoReplaceList.Add("wont", "won't") ' activate as-you-type spell-checking on the RichTextBox C1SpellChecker1.SetActiveSpellChecking(RichTextBox1, True) |
To write code in C#
C# |
Copy Code
|
---|---|
// build AutoReplace list c1SpellChecker1.AutoReplaceList.Clear(); c1SpellChecker1.AutoReplaceList.Add("becuase", "because"); c1SpellChecker1.AutoReplaceList.Add("cant", "can't"); c1SpellChecker1.AutoReplaceList.Add("recieve", "receive"); c1SpellChecker1.AutoReplaceList.Add("teh", "the"); c1SpellChecker1.AutoReplaceList.Add("wont", "won't"); // activate as-you-type spell-checking on the RichTextBox c1SpellChecker1.SetActiveSpellChecking(richTextBox1, true); |
This code builds the following list using the AutoReplaceList.Add method:
Misspelled word | Correction word |
---|---|
because | because |
cant | can't |
receive | receive |
the | the |
wont | won't |
Then it activates as-you-type spell-checking on the RichTextBox control using the SetActiveSpellChecking method.
Run the application and observe the following: