ASPxSpellCheckerCustomDictionary.AddWord(String) Method
Appends a word to a custom dictionary.
Namespace: DevExpress.Web.ASPxSpellChecker
Assembly: DevExpress.Web.ASPxSpellChecker.v18.2.dll
Declaration
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.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-load-a-user-specific-dictionary-and-update-it-during-spelling-check-e3002
using DevExpress.Web.ASPxSpellChecker;
using DevExpress.XtraSpellChecker;
protected void ASPxSpellChecker1_WordAdded(object sender, WordAddedEventArgs e) {
ASPxSpellChecker checker = sender as ASPxSpellChecker;
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(userDictPath)) {
writer.Write(stb.ToString());
}
}
}