Skip to main content

ASPxSpellCheckerCustomDictionary.AddWord(String) Method

Appends a word to a custom dictionary.

Namespace: DevExpress.Web.ASPxSpellChecker

Assembly: DevExpress.Web.ASPxSpellChecker.v23.2.dll

NuGet Package: DevExpress.Web

Declaration

public virtual void AddWord(
    string word
)

Parameters

Name Type Description
word String

A string, representing a word to add.

Remarks

The method changes the letters in a word to the lower case, appends a word to the custom dictionary, fills in the corresponding metaphones, sorts the dictionary, saves it to the session and rebuilds the dictionary’s alphabet.

Note

To save a dictionary to a file for subsequent use, handle the ASPxSpellChecker.WordAdded event and write words from dictionary to a stream.

This code illustrates that you can handle the ASPxSpellChecker.WordAdded event to save an updated custom dictionary to the original location. The ASPxSpellChecker.GetCustomDictionary method enables you to access a custom dictionary that is currently in use.

View Example

using DevExpress.Web.ASPxSpellChecker;
using DevExpress.XtraSpellChecker;
protected void ASPxSpellChecker1_WordAdded(object sender, WordAddedEventArgs e) {
    ASPxSpellChecker checker = send as ASPxSpellChecker;
    if (checker != null) {
        SpellCheckerCustomDictionary dic = checker.GetCustomDictionary();
        if (dic != null) {
            StringBuilder stb = new StringBuilder();
            for (int i = 0; i < dic.WordCount; i++) stb.AppendLine(dic[i]);
            using (StreamWriter writer = new StreamWriter(dic.DictionaryPath,false, Encoding.UTF8)) {
                writer.Write(stb.ToString());
            }
        }
    }
}
See Also