windowsforms-116931-controls-and-libraries-spell-checker-examples-how-to-customize-the-spelling-dialog.md
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.
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) });
}
Private Sub spellChecker1_SpellingFormShowing(ByVal sender As Object, ByVal e As DevExpress.XtraSpellChecker.SpellingFormShowingEventArgs) Handles spellChecker1.SpellingFormShowing
Dim spellDialogForm = spellChecker1.FormsManager.SpellCheckForm
spellDialogForm.Controls("btnIgnore").Enabled = False
spellDialogForm.Controls("btnIgnoreAll").Visible = False
spellDialogForm.Controls("btnChangeAll").Visible = False
spellDialogForm.Controls.Add(New SimpleButton() With {.Text = "Custom Button", .Size = New Size(100, 25), .Location = New Point(10, 150)})
End Sub
The following image illustrates a customized Spelling Dialog.
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 |
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:
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;
}
Private Sub SpellChecker1_FinishCheckingMainPart(ByVal sender As Object, ByVal e As FinishCheckingMainPartEventArgs)
e.NeedCheckRemainingPart = False
End Sub
The SpellChecker.CheckCompleteFormShowing event allows you to hide the Spelling Check Is Complete message.
Set the Handled parameter to true in the event handler to disable this message.