Skip to main content

SpellCheckerSettings.WordAdded Property

The event fires when a word is added to the custom dictionary.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v24.1.dll

NuGet Package: DevExpress.Web.Mvc5

Declaration

public WordAddedEventHandler WordAdded { get; set; }

Property Value

Type Description
WordAddedEventHandler

A WordAddedEventHandler delegate method to be called when a word is added to a custom dictionary.

Remarks

Use the WordAdded event to save the custom dictionary to an arbitrary location. Currently, the custom dictionary is stored in a session and cannot be shared between users. Collaboration can be established by providing two delegates - the WordAdded event handler to save a changed dictionary and the SpellCheckerSettings.CustomDictionaryLoading event to load the dictionary.

The added word is available via the WordAddedEventArgs.Word property.

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