SpellCheckGrid () Sub Routine

The SpellCheckGrid () sub routine simply loops through all the rows on the batch user interface grid and calls SpellCheck () for the Name and Description columns. We grab the column numbers for the Name and Description columns using the base class's GetColumnIndexFromFieldID to ensure we have the correct location of these columns since the numbers for these columns could deviate from the various templates based off this batch type. To provide the looping, we utilize the base class's RowCount property. For each row, we retrieve a DataFormItem object that represents the series of form field metadata and values. Next we ensure the value within the Name and Description columns are not null. We pass the value into the SpellCheck routine and then update the grid with UpdateCell.

Private Sub SpellCheckGrid()
        'The SpellCheckGrid () sub routine simply loops through all the rows on the 
        'batch user interface grid and calls SpellCheck () for the Name and Description columns.   
        Dim NameColumnNumber, DescColumnNumber As Integer

        'We grab the column numbers for the Name and Description columns 
        'using the base class’ GetColumnIndexFromFieldID to ensure we have 
        'the correct location of these columns since the numbers for these 
        'columns could deviate from the various templates based off this batch type.
        NameColumnNumber = Me.GetColumnIndexFromFieldID("NAME")
        DescColumnNumber = Me.GetColumnIndexFromFieldID("DESCRIPTION")

        'To provide the looping we will utilize the base class’ RowCount property.   
        For x As Integer = 0 To Me.RowCount - 1
            'For each row we will retrieve a DataFormItem object 
            'which represents the series of form field Meta data and values.
            Dim dfi As DataFormItem
            dfi = Me.GetRow(x)

            'Check the NAME column
            Dim TextNeedingSpellChecking As String
            Dim SpellCheckResults As String = ""
            'Next we ensure the value within the Name and Description columns are not null.  
	     'We pass the value into the SpellCheck routine and then update the grid with                                                                                                                               	     ‘UpdateCell.    
            If Not IsDBNull(dfi.Values("NAME").Value) Then
                TextNeedingSpellChecking = CType(dfi.Values("NAME").Value, String)
                SpellCheckResults = SpellCheck(TextNeedingSpellChecking)
                Me.UpdateCell(x, NameColumnNumber, SpellCheckResults, SpellCheckResults)
            End If

            'Check the DESCRIPTION column
            If Not IsDBNull(dfi.Values("DESCRIPTION").Value) Then
                TextNeedingSpellChecking = ""
                TextNeedingSpellChecking = CType(dfi.Values("DESCRIPTION").Value, String)
                SpellCheckResults = ""
                SpellCheckResults = SpellCheck(TextNeedingSpellChecking)
                Me.UpdateCell(x, DescColumnNumber, SpellCheckResults, SpellCheckResults)
            End If
        Next
        MsgBox("Spell Check Complete", MsgBoxStyle.OkOnly, "Spell Check")
    End Sub