Skip to main content

Check Spelling in Different Controls

  • 4 minutes to read

The SpellChecker component provides the capability to check text in a wide range of text-aware controls. To see a list of controls supported by SpellChecker, see the Supported Controls topic. This document describes methods for enabling spell check in your application.

Check a Control

To enable the control to be processed by SpellChecker, the control’s CanCheckText on spellChecker property must be set to True. To modify this property, you can use the Properties window at design time within Visual Studio, or set this property at runtime using the SpellChecker.GetCanCheckText and SpellChecker.SetCanCheckText methods.

To check the text within a control, call the SpellChecker.Check method with this control as a parameter:

private void simpleButton1_Click(object sender, EventArgs e) {

Check Any Text-Aware Control

The SpellChecker.Check method can check text from any control. Just pass the text value to the Check method and you’ll be returned the text processed by the spell-checker engine.

myTextControl.Text = spellChecker1.Check(myTextControl.Text);

Check Controls in a Container

The SpellChecker component provides the capability to check the text of controls placed in a control container. You can do this by calling the SpellChecker.CheckContainer method, with this container as a parameter. The controls in the container (the only controls allowed to be checked, where the value of the CanCheckText on spellChecker property is True) are checked in their tab order according to the SpellChecker options customized for each individual control.

private void simpleButton1_Click(object sender, EventArgs e) {


Only use the SpellingFormType.Outlook setting of the SpellChecker when the SpellChecker.CheckContainer method is executed.

Check All Controls On a Form

To check all supported controls on a form, just call the SpellChecker.CheckContainer method.


Check-As-You-Type for All Controls On a Form

To switch the check-as-you-type mode for all supported controls on a form, set the SpellChecker.ParentContainer property to the current form and set the CheckAsYouTypeOptions.CheckControlsInParentContainer property to true, as in the following code:

spellChecker1.SpellCheckMode = DevExpress.XtraSpellChecker.SpellCheckMode.AsYouType;
spellChecker1.ParentContainer = this;
spellChecker1.CheckAsYouTypeOptions.CheckControlsInParentContainer = true;

Register Custom Controls

Usually, a set of supported controls can cover your requirements. In other situations, you can send the text to be checked (for example, the value of the control’s Text property) to the SpellChecker as a string, calling the SpellCheckerBase.Check method of the spell checker instance with a string argument. In this case, the Spelling Dialog is invoked when the process requires user interaction. The method returns a string of corrected text.

If a control does not belong to any of the supported types, you can create a custom controller for your control. The controller should implement the DevExpress.XtraSpellChecker.Parser.ISpellCheckTextController interface, to allow the SpellChecker to interact with it.

To register your control to enable spell checking, use the SpellCheckTextControllersManager.Default.RegisterClass method, and pass the type of your editor and TextController classes. If your editor is a TextEdit descendant, you can use the following code:

using DevExpress.XtraSpellChecker.Native;
// ...


If the editor is derived from the standard TextBox class, the code should be:


To allow checking with the SpellChecker.SpellCheckMode property set to SpellCheckMode.AsYouType, an additional registration procedure is needed. Call the SpellCheckTextBoxBaseFinderManager.Default.RegisterClass method of the DevExpress.XtraSpellChecker.Native namespace, as illustrated in the code snippet below:

using DevExpress.XtraSpellChecker.Native;

// The second parameter passed to the RegisterClass method 
// depends on the class from which the YourEditorClass inherits, as follows:
// System.Windows.Forms.TextBox - typeof(TextBoxFinder)
// DevExpress.XtraEditors.TextEdit - typeof(TextEditTextBoxFinder)
// DevExpress.XtraEditors.MemoEdit - typeof(MemoEditTextBoxFinder)
// System.Windows.Forms.RichTextBox - typeof(RTFTextBoxFinder)

The control must be registered by calling this code, prior to calling the SpellChecker.Check method. Call the SpellCheckTextBoxBaseFinderManager.Default.UnregisterClass method to disable spelling check.

See Also