We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to perform SpellChecker in WinForms GridControl, GridGroupingControl and GridDataBoundGrid?

Platform: WinForms |
Control: GridGroupingControl
Tags: spellcheck


The Essential Grid does not have direct support for SpellChecker. In order to achieve SpellChecker in Grid, you need to customize the Grid by creating the custom cell renderer and cell model. Refer to the following article link to know more about the creating cell renderer and cell model

How to create the Cell Model and Cell Renderer?


In this article, the SpellChecker component is used to validate the strings in the cell. Based on the result, the cell text is underlined when the text is misspelled, since customization for multiple words is not provided. To know more about the SpellChecker component, you can refer to the following link: Spellchecker

Creating cell renderer and cell model:


public class SpellCheckCellRenderer : GridTextBoxCellRenderer
    //Using SpellChecker tool.
    private SpellChecker spellchecker;
    public SpellCheckCellRenderer(GridControlBase grid, GridCellModelBase cellModel) : base(grid, cellModel)
        spellchecker = new SpellChecker();
    //To underline the word in cell that is misspelled.
    protected override void OnDraw(Graphics g, Rectangle clientRectangle, int rowIndex, int colIndex, GridStyleInfo style)
       //Validate the cell values.
       string check = this.spellchecker.SpellCheck(style.CellValue.ToString());
       //Checking whether the result has suggestions.
       if(check != "")
          style.Font.Underline = true;
       base.OnDraw(g, clientRectangle, rowIndex, colIndex, style);
public class SpellCheckCellModel : GridTextBoxCellModel
    ///Initializes a new <see cref="PercentTextBoxCellModel"/>
    ///<param name="grid">GridModel.</param>
    public SpellCheckCellModel(GridModel grid) : base(grid)
    {    }
    /// <summary>
    /// Creates a cell renderer.
    /// </summary>
    /// <param name="control">GridControlBase</param>
    /// <returns>A new <see cref="PercentTextBoxCellRenderer"/>specific for a <see cref="GridControlBase"/></returns>
    public override GridCellRendererBase CreateRenderer(GridControlBase control)
        return new SpellCheckCellRenderer(control, this);


Public Class SpellCheckCellRenderer
    Inherits GridTextBoxCellRenderer
    Private spellchecker As SpellChecker
    Public Sub New(ByVal grid As GridControlBase, ByVal cellModel As GridCellModelBase)
       MyBase.New(grid, cellModel)
       spellchecker = New SpellChecker()
    End Sub
    ‘To underline the word in cell that is misspelled.
    Protected Overrides Sub OnDraw(ByVal g As Graphics, ByVal clientRectangle As Rectangle, ByVal rowIndex As Integer, ByVal colIndex As Integer, ByVal style As GridStyleInfo)
       If style.CellValue IsNot Nothing Then
          Dim check As String = Me.spellchecker.SpellCheck(style.CellValue.ToString())
          'To check whether value has suggestion.
          If check <> "" Then
   style.Font.Underline = True
          End If
       End If
       MyBase.OnDraw(g, clientRectangle, rowIndex, colIndex, style)
    End Sub
End Class
Public Class SpellCheckCellModel
    Inherits GridTextBoxCellModel
    '''Initializes a new <see cref="PercentTextBoxCellModel"/>
    '''<param name="grid">GridModel.</param>
    Public Sub New(ByVal grid As GridModel) 
    End Sub 
    ''' <summary>
    ''' Creates a cell renderer.  
    ''' </summary>
    ''' <param name="control">GridControlBase</param>
    ''' <returns>A new <see cref="PercentTextBoxCellRenderer"/>specific for a <see cref="GridControlBase"/></returns>
    Public Overrides Function CreateRenderer(ByVal control As GridControlBase) As GridCellRendererBase
       Return New SpellCheckCellRenderer(control, Me)
    End Function
End Class

Adding cell model and assigning CellType:

For GridControl:


//Add the Custom Cell Model to Grid.
this.gridControl1.CellModels.Add("SpellCheckCell", new SpellCheckCellModel(this.gridControl1.Model));
//Set the Custom Cell Type.
this.gridControl1.TableStyle.CellType = "SpellCheckCell";


'Add the Custom Cell Model to Grid.
Me.gridControl1.CellModels.Add("SpellCheckCell", New SpellCheckCellModel(Me.gridControl1.Model))
'Set the Custom Cell Type.
Me.gridControl1.TableStyle.CellType = "SpellCheckCell"

For GridGroupingControl:


//Add the Custom Cell Model to Grid.
this.gridGroupingControl1.TableModel.CellModels.Add("SpellCheckCell", new SpellCheckCellModel(this.gridGroupingControl1.TableModel));
//Set the Custom Cell Type.
this.gridGroupingControl1.TableDescriptor.Columns[1].Appearance.AnyRecordFieldCell.CellType = "SpellCheckCell";


'Add the Custom Cell Model to Grid.
Me.gridGroupingControl1.TableModel.CellModels.Add("SpellCheckCell", New SpellCheckCellModel(Me.gridGroupingControl1.TableModel))
'Set the Custom Cell Type.
Me.gridGroupingControl1.TableDescriptor.Columns(1).Appearance.AnyRecordFieldCell.CellType = "SpellCheckCell"

For GridDataBoundGrid:


//Add the Custom Cell Model to Grid.
this.gridDataBoundGrid1.Model.CellModels.Add("SpellCheckCell", new SpellCheckCellModel(this.gridDataBoundGrid1.Model));
//Set the Custom Cell Type.
this.gridDataBoundGrid1.Binder.InternalColumns[1].StyleInfo.CellType = "SpellCheckCell";


'Add the Custom Cell Model to Grid.
Me.gridDataBoundGrid1.Model.CellModels.Add("SpellCheckCell", New SpellCheckCellModel(Me.gridDataBoundGrid1.Model))
'Set the Custom Cell Type.
Me.gridDataBoundGrid1.Binder.InternalColumns(1).StyleInfo.CellType = "SpellCheckCell"


Show the spell checking process in grid

Figure 1: Output



C#: SpellChecker_GridControl_CS

VB: SpellChecker_GridControl_VB


C#: SpellChecker_GGC_CS

VB: SpellChecker_GGC_VB


C#: SpellChecker_GDBG_CS

VB: SpellChecker_GDBG_VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile