Back to Devexpress

SpellCheckOptions.MaxSuggestionCount Property

blazor-devexpress-dot-blazor-dot-richedit-dot-spellcheck-dot-spellcheckoptions-4ad64760.md

latest3.7 KB
Original Source

SpellCheckOptions.MaxSuggestionCount Property

Specifies the maximum number of suggestions the context menu should display.

Namespace : DevExpress.Blazor.RichEdit.SpellCheck

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

NuGet Package : DevExpress.Blazor.RichEdit

Declaration

csharp
[DefaultValue(5)]
public int MaxSuggestionCount { get; set; }

Property Value

TypeDefaultDescription
Int325

The maximum number of suggestions.

|

Remarks

The built-in spell check service uses dictionaries to generate a spelling suggestion list. The Rich Text Editors displays the suggested words and phrases in the context menu. When the service generates no suggestions, the context menu displays No suggestions.

The context menu can display up to 15 suggestions. The MaxSuggestionCount property specifies the maximum number of suggestions the context menu should display. For instance, if you set this property to 3, the context menu displays up to 3 suggestions. If the service generates more than 3 suggestions, the context menu displays only the first 3 suggestions.

The following code snippet sets the maximum number of suggestions:

csharp
public void ConfigureServices(IServiceCollection services) {
    services.AddDevExpressBlazor().AddSpellCheck(opts => {
        opts.FileProvider = new PhysicalFileProvider(
            Path.Combine(Directory.GetCurrentDirectory(), "Data", "Dictionaries")
        );
        opts.MaxSuggestionCount = 7;
        opts.Dictionaries.Add(new Dictionary {
            DictionaryPath = "CustomEnglish.dic",
            AlphabetPath = "EnglishAlphabet.txt",
            Culture = "en-US"
        });
        opts.AddToDictionaryAction = (word, culture) => {
            switch (culture.Name) {
                case "en-US":
                    string path = opts.FileProvider.GetFileInfo("CustomEnglish.dic").PhysicalPath;
                    File.AppendAllText(path, word);
                    break;
                default:
                    break;
            };
        };
    });
}

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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the MaxSuggestionCount 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.

blazor-richedit-spell-check/CS/SpellCheck/Program.cs#L35

csharp
};
    opts.MaxSuggestionCount = 7;
});

See Also

SpellCheckOptions Class

SpellCheckOptions Members

DevExpress.Blazor.RichEdit.SpellCheck Namespace