# SpellChecking RadGridView

**RadSpellChecker** is not limited to checking only simple text-editing controls such as **RadTextBox**. It can spell check editors in more complex controls such as **RadGridView** as well.

Here is a sample scenario: the end-user types something in **RadTextBoxEditor** in **RadGridView** and tries to commit the typed text in the cell. This is the place where **RadSpellChecker** should appear and correct the misspelled words.  After a confirmation given by the end-user on the **RadSpellChecker** form, the editor should close and the corrected values should be committed to the edited cell.

Supposing that we have a **RadGridView** filled with data and a **RadSpellChecker** on the form, the following steps demonstrate how to implement the given scenario:

1\. Let's subscribe to **CellValidating** event. This event is fired when the edited cell should be validated before the editor for that particular cell is closed. In this event we should call the **Check** method of **RadSpellChecker** passing the currently opened editor:

#### Spell check RadGridView's editor

```C#
string correctedValue = string.Empty;

void radGridView1_CellValidating(object sender, Telerik.WinControls.UI.CellValidatingEventArgs e)
{
    RadTextBoxEditor editor = e.ActiveEditor as RadTextBoxEditor;
    if (editor != null)
    {
        RadTextBoxEditorElement element = editor.EditorElement as RadTextBoxEditorElement;
        this.radSpellChecker1.Check(element.TextBoxItem.HostedControl);
        this.correctedValue = e.ActiveEditor.Value.ToString();
    }
}
```

```VB.NET
Dim correctedValue As String = String.Empty

Private Sub RadGridView1_CellValidating(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.CellValidatingEventArgs) Handles RadGridView1.CellValidating
    Dim editor As RadTextBoxEditor = TryCast(e.ActiveEditor, RadTextBoxEditor)
    If editor IsNot Nothing Then
        Dim element As RadTextBoxEditorElement = TryCast(editor.EditorElement, RadTextBoxEditorElement)
        Me.RadSpellChecker1.Check(element.TextBoxItem.HostedControl)
        Me.correctedValue = e.ActiveEditor.Value.ToString()
    End If
End Sub
```

Please note that the editor sets the corrected value to the opened editor, but not directly to the underlying data cell. We save this editor value in a variable named '*correctedValue*'

2\. Now we should subscribe to the **CellEndEdit** event which is fired after the editor is closed. In this event we should pass the saved corrected value to the data cell:

#### Save the corrected value

```C#
void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
{
    this.radGridView1.CurrentRow.Cells[this.radGridView1.CurrentColumn.Name].Value = this.correctedValue;
}
```

```VB.NET
Private Sub RadGridView1_CellEndEdit(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles RadGridView1.CellEndEdit
    Me.RadGridView1.CurrentRow.Cells(Me.RadGridView1.CurrentColumn.Name).Value = Me.correctedValue
End Sub
```

The following figures provide the end-user experience with **RadSpellChecker** and **RadGridView**:

1. The end-user types '*Sales Representativ*':

   ![WinForms RadSpellChecker Editing Cell](https://www.telerik.com/products/winforms/documentation/assets/0aeff12c7a3fa0c8afb0a89d8707c88d/spellchecker-spellchecking-radgridview001.png)

2. Then the end-user tries to commit the misspelled value by pressing the Enter key. As a consequence, the **RadSpellChecker** form is invoked:

   ![WinForms RadSpellChecker Form](https://www.telerik.com/products/winforms/documentation/assets/370c590bcaa5e52a4adcece61aa60ca3/spellchecker-spellchecking-radgridview002.png)

3. After the user chooses one of the suggestions and presses the `Change` button, the **RadSpellChecker** form disappears, leaving an informative message box that the spell checking operation is completed:

   ![WinForms RadSpellChecker Success Dialog](https://www.telerik.com/products/winforms/documentation/assets/fe27f9daf98c78d4d50f78282300d732/spellchecker-spellchecking-radgridview003.png)

4. The end-user pressed the `OK` button. Then, the message box disappears, the editor closes and the corrected value is saved in the cell:

   ![WinForms RadSpellChecker Cell Text After Correcting the Value](https://www.telerik.com/products/winforms/documentation/assets/30485b0a267e9afbcf9e53d150c3ab48/spellchecker-spellchecking-radgridview004.png)

## See Also

* [Spellchecking Modes](https://www.telerik.com/products/winforms/documentation/controls/spellchecker/spellchecking-modes)
