Back to Devexpress

SpellCheckerBase.PrepareSuggestions Event

corelibraries-devexpress-dot-xtraspellchecker-dot-spellcheckerbase-c42fa20a.md

latest2.7 KB
Original Source

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.v25.2.Core.dll

NuGet Package : DevExpress.SpellChecker.Core

Declaration

csharp
public event PrepareSuggestionsEventHandler PrepareSuggestions
vb
Public Event PrepareSuggestions As PrepareSuggestionsEventHandler

Event Data

The PrepareSuggestions event's data class is PrepareSuggestionsEventArgs. The following properties provide information specific to this event:

PropertyDescription
SuggestionsProvides access to the collection of prepared suggestions.
WordGets 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.

csharp
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));
}
vb
Private Sub spellChecker1_PrepareSuggestions(ByVal sender As Object, ByVal e As PrepareSuggestionsEventArgs)
    Dim pattern As String = "(De|de)[a-z]+x[a-z]*s+"
    Dim rgx As New System.Text.RegularExpressions.Regex(pattern)
    If rgx.IsMatch(e.Word) Then
        e.Suggestions.Insert(0, New SuggestionBase("DevExpress", 0))
    End If
End Sub

See Also

SpellCheckerBase Class

SpellCheckerBase Members

DevExpress.XtraSpellChecker Namespace