How to: Check Spelling of a Grid Cell

  • 2 minutes to read

The following example demonstrates how to check the spelling of a GridControl cell's content:

  1. Implement the DXSpellChecker behavior for the GridControl. Refer to the Lesson 3 - Configure Spelling Check in XAML topic for details.
  2. Handle a current GridControl view's GridViewBase.ShownEditor event that is raised when the grid cell is activated. Retrieve the active editor and run the spell checker as shown below:

    View Example

    private void CardView_ShownEditor(object sender, EditorEventArgs e)
    {
        var cardView = (sender as CardView);
        BaseEdit activeEditor = cardView.ActiveEditor;
        if (SpellChecker.SpellCheckMode == DevExpress.XtraSpellChecker.SpellCheckMode.OnDemand)
            CheckActiveEditor(activeEditor);
    }
    void CheckActiveEditor(BaseEdit activeEditor)
    {
        activeEditor.Dispatcher.BeginInvoke(new Action(() =>
        {
            if (SpellChecker.CanCheck(activeEditor))
                SpellChecker.Check(activeEditor);
        }), DispatcherPriority.Loaded);
    }
    
  3. In the SpellChecker.CheckCompleteFormShowing event handler, set the Handled property to true to prevent showing The spelling check is complete dialog box when the grid control's editor does not contain errors:

    View Example

    void Checker_CheckCompleteFormShowing(object sender, DevExpress.XtraSpellChecker.FormShowingEventArgs e)
    {
        e.Handled = true;
    }
    
  4. As a result, the spelling form is invoked when the editor is activated. If the SpellingSettings.CheckAsYouType property is set to true, the misspelled words are highlighted.

    DXSpellChecker_GridCell