SpellCheckerBase.PrepareSuggestions Event
Occurs when a misspelled word is found and a list of suggested replacements is created and sorted.
Namespace: DevExpress.XtraSpellChecker
Assembly: DevExpress.SpellChecker.v19.2.Core.dll
Declaration
Event Data
The PrepareSuggestions event's data class is PrepareSuggestionsEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Suggestions | Provides access to the collection of prepared suggestions. |
Word | Gets a misspelled word for which the suggestions have been prepared. |
Example
The following code of the SpellCheckerBase.PrepareSuggestions
event handler checks whether the misspelled word matches the specified pattern. If it does, a word to replace the misspelled word is added to the list of suggestions in the SpellChecker context menu.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-display-spellchecker-context-menu-for-standard-text-controls-textbox-and-richtextbox-t236002
void spellChecker1_PrepareSuggestions(object sender, PrepareSuggestionsEventArgs e)
{
string pattern = "(De|de)[a-z]+x[a-z]*s+";
System.Text.RegularExpressions.Regex rgx = new System.Text.RegularExpressions.Regex(pattern);
if (rgx.IsMatch(e.Word)) e.Suggestions.Insert(0, new SuggestionBase("DevExpress", 0));
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the PrepareSuggestions event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.