How To: Customize the Spelling Dialog

  • 3 minutes to read

Customize the Dialog

This example demonstrates how to customize the spell checker's Spelling Dialog and the messages that occur when the spelling check is complete.

You can modify layouts of both Outlook-inspired and Word-inspired Spelling Dialogs by doing the following.

  1. Handle the SpellChecker.SpellingFormShowing event. It is raised when the form is about to be shown.
  2. Retrieve the Spelling Dialog's form from the SpellChecker.FormsManager collection.
  3. Modify the form's Controls collection to hide default buttons and/or to add custom control.

View Example

private void spellChecker1_SpellingFormShowing(object sender, DevExpress.XtraSpellChecker.SpellingFormShowingEventArgs e)
{
    var spellDialogForm = spellChecker1.FormsManager.SpellCheckForm;

    spellDialogForm.Controls["btnIgnore"].Enabled = false;
    spellDialogForm.Controls["btnIgnoreAll"].Visible = false;
    spellDialogForm.Controls["btnChangeAll"].Visible = false;
    spellDialogForm.Controls.Add(new SimpleButton() { Text = "Custom Button", Size = new Size(100, 25), Location = new Point(10, 150) });
}

The following image illustrates a customized Spelling Dialog.

SpellingDialog_Customized

Table of Controls

The code sample above utilizes default control names to access them. The following table gives names for all of these default controls, owned by a spelling dialog.

Element Caption Control Element Name
Add to Dictionary (Add) button SimpleButton btnAdd
Cancel button SimpleButton btnCancel
Change button SimpleButton btnChange
Change All button SimpleButton btnChangeAll
Close button SimpleButton btnClose
Ignore Once (Ignore) button SimpleButton btnIgnore
Ignore All button SimpleButton btnIgnoreAll
Undo Last button SimpleButton btnUndoLast
Not In Dictionary label LabelEdit lblNotInDictionary
Suggestions label LabelEdit lblSuggestions
Repeated Word label LabelEdit lblRepeatedWord
Delete button SimpleButton btnDelete
Not in Dictionary memo edit (Word-type form) CustomSpellCheckMemoEdit mmNotInDictionary
Suggestions list box ListBoxControl lbcSuggestions
Options button SimpleButton btnOptions
Not in Dictionary text edit (Outlook-type form) TextEdit txtNotInDictionary
Change to: text edit (Outlook-type form) TextEdit txtChangeTo

Disable Messages

If the end user checks spelling of a selection in a text editor (MemoEdit or RichTextBox), the following message appears after the check is complete:

selection checked

Handle the SpellCheckerBase.FinishCheckingMainPart event to specify whether to check the remaining text and hide the message. Specify the FinishCheckingMainPartEventArgs.NeedCheckRemainingPart property as shown below:

private void SpellChecker1_FinishCheckingMainPart(object sender, FinishCheckingMainPartEventArgs e)
{
    e.NeedCheckRemainingPart = false;
}

The SpellChecker.CheckCompleteFormShowing event allows you to hide the Spelling Check Is Complete message.

check complete

Set the Handled parameter to true in the event handler to disable this message.