Skip to main content
All docs
V25.2
  • 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.v25.2.dll

    NuGet Package: DevExpress.Blazor.RichEdit

    Declaration

    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:

    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 additional information: Spell Check.

    The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AddToDictionaryAction property.

    Note

    The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

    See Also