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:
- Implement the DXSpellChecker behavior for the GridControl. Refer to the Lesson 3 - Configure Spelling Check in XAML topic for details.
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:
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-check-spelling-of-an-active-grid-cell-t598294.
Private Sub CardView_ShownEditor(ByVal sender As Object, ByVal e As EditorEventArgs) Dim cardView = (TryCast(sender, CardView)) Dim activeEditor As BaseEdit = cardView.ActiveEditor If SpellChecker.SpellCheckMode = DevExpress.XtraSpellChecker.SpellCheckMode.OnDemand Then CheckActiveEditor(activeEditor) End If End Sub Private Sub CheckActiveEditor(ByVal activeEditor As BaseEdit) activeEditor.Dispatcher.BeginInvoke(New Action(Sub() If SpellChecker.CanCheck(activeEditor) Then SpellChecker.Check(activeEditor) End If End Sub), DispatcherPriority.Loaded) End Sub
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:
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-check-spelling-of-an-active-grid-cell-t598294.
Private Sub Checker_CheckCompleteFormShowing(ByVal sender As Object, ByVal e As DevExpress.XtraSpellChecker.FormShowingEventArgs) e.Handled = True End Sub
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.