Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

SpellCheckOptions.AddToDictionaryAction Property

Allows you to implement a delegate method that writes the selected word to a dictionary file.

Namespace: DevExpress.Blazor.RichEdit.SpellCheck

Assembly: DevExpress.Blazor.RichEdit.v24.2.dll

NuGet Package: DevExpress.Blazor.RichEdit

#Declaration

C#
public Action<string, CultureInfo> AddToDictionaryAction { get; set; }

#Property Value

Type Description
Action<String, CultureInfo>

A delegate method that writes the selected word to a file.

#Remarks

Assign a delegate method to the AddToDictionaryAction property to show the Add to dictionary command in the context menu. After a user clicks this command, the component passes the selected word and the current document culture to the delegate method. In the method, write the word to a dictionary file depending on the document culture.

The following code snippet adds a simple dictionary and use it as a storage for new words:

C#
var DictionaryFiles = new Dictionary<string, string>() {
    { "de-DE", "de//de.dic" },
    // ...
};
var builder = WebApplication.CreateBuilder(args);
// ...
builder.Services.AddDevExpressBlazor().AddSpellCheck(opts => {
    opts.FileProvider = new PhysicalFileProvider(
        Path.Combine(Directory.GetCurrentDirectory(), "Data", "Dictionaries"));
    opts.Dictionaries.Add(new Dictionary {
        DictionaryPath = "de\\de.dic",
        AlphabetPath = "de\\alphabet.txt",
        Culture = "de-DE"
    });
    // ...
    opts.AddToDictionaryAction = (word, culture) => {
        string dictionaryFile = DictionaryFiles.GetValueOrDefault(culture.Name);
        if (dictionaryFile != default) {
            var filePath = opts.FileProvider.GetFileInfo(dictionaryFile).PhysicalPath;
            File.AppendAllText(filePath, "\n" + word);
        }
    };
    opts.MaxSuggestionCount = 7;
});

View Example: How to Customize the Built-in Spell Check Services

Refer to the following topic for more information: Spell Check.

See Also