LeaveCell Event Handler

Our FoodItemAddBatchEventHandler class inherits from the Blackbaud.AppFx.Browser.Batch.BatchEntryHandler, which we will simply call BatchEntryHandler. BatchEntryHandler emits an event named LeaveCell. By handling this event within our FoodItemAddBatchEventHandler class, we can utilize the Blackbaud.AppFx.Browser.Batch.BatchLeaveCellEventArgs to uncover the column, row, and value of the cell that was vacated. We can pass the value of the cell via the event argument's Value property into the SpellCheck () function to check the text. After the spell check is complete, we can call up the base class's UpdateCell to update the cell with the corrected spellings. UpdateCell requires the coordinates of the row and column to update which are provided by the event arguments.

Private Sub FoodItemAddBatch_LeaveCell(ByVal sender As Object, _
                                           ByVal e As Browser.Batch.BatchLeaveCellEventArgs) _
                                           Handles Me.LeaveCell
        'Our FoodItemAddBatchEventHandler class inherits from the 
        'Blackbaud.AppFx.Browser.Batch.BatchEntryHandler, which 
        'we will simply call BatchEntryHandler.   
        'BatchEntryHandler emits an event named LeaveCell.  
        'By handling this event within our FoodItemAddBatchEventHandler class, 
        'we can utilize the Blackbaud.AppFx.Browser.Batch.BatchLeaveCellEventArgs 
        'to uncover the column, row, and value of the cell that was vacated.

        If Not IsDBNull(e.Value) Then
            If Me.GetColumnIndexFromFieldID("NAME") = e.Column OrElse Me.GetColumnIndexFromFieldID("DESCRIPTION") = e.Column Then

                Dim TextNeedingSpellChecking As String = CType(e.Value, String)
                Dim SpellCheckResults As String = ""
                'We can pass the value of the cell into the SpellCheck() function 
                'to spell check the text.  Once the spell check is complete, 
                'we can update the grid with the corrected spellings.  
                SpellCheckResults = SpellCheck(TextNeedingSpellChecking)
                'UpdateCell requires the coordinates of the row and column to 
                'update which are provided by the event arguments.  
                Me.UpdateCell(e.Row, e.Column, SpellCheckResults, SpellCheckResults)
            End If
        End If
    End Sub