sgray128 3/3/2014 8:16:57 AM

Winforms - GridView - ValueChanged event

This short code snippet is to be used as a sample for the RadGrid ValueChanged event                       


Private Sub RadGridView2_ValueChanged(sender As Object, e As System.EventArgs) Handles RadGridView2.ValueChanged
    'when the check box is checked, complete the edit
    If TypeOf sender Is RadCheckBoxEditor Then
    End If
End Sub


Private Sub RadGridView1_ValueChanged(sender As Object, e As EventArgs) Handles RadGridView1.ValueChanged
    'CellValueChanged fires after the user leaves the fields.
    'The 'sender' will not be used, we'll get what we need through e.row and e.coumn
    'ValueChanged fires while the editor is still open, after every key stroke
    'normally, we'd avoid that but it's good for changes fired off by a check box header change
        'if this is called by a direct edit, we'll get an 'editor' control in the sender.
        'if this is called by a click in the check box editor HEADER, we get a GridViewCellInfo object
        If TypeOf (sender) Is RadCheckBoxEditor Or TypeOf (sender) Is RadTextBoxEditor Or TypeOf (sender) Is RadDateTimeEditor Then
            Exit Sub
        End If
        Dim ci As GridViewCellInfo = sender
        If ci.ColumnInfo.Name = "DNI" Then
            'Dim chk As RadCheckBoxEditor = CType(sender, RadCheckBoxEditor)
            Dim oRow As GridViewDataRowInfo = ci.RowInfo
            Dim oCol As GridViewDataColumn = ci.ColumnInfo
            Dim intRowID As Integer = oRow.Cells("RowID").Value
            'If TypeOf (oRow) Is GridViewFilteringRowInfo Then
            '    Exit Sub
            'End If
            Dim oSOP As New SOPIntegrationWork(intRowID)
            If oSOP.CUSTNMBR Is Nothing Then
                Exit Sub
            End If
            oSOP.DNI = Common.ToStr(oRow.Cells("DNI").Value)
        End If
    Catch ex As Exception
        ErrorHandler.globalErrorHandler(ex, True)
    End Try
End Sub