AddHandler Me.sfDataGrid1.CurrentCellKeyPress, AddressOf SfDataGrid1_CurrentCellKeyPress
Private Sub SfDataGrid1_CurrentCellKeyPress(ByVal sender As Object, ByVal e As CurrentCellKeyPressEventArgs)
Value = textBox1.Text
Value1 = Boolean.Parse(textBox2.Text)
Dim r As Integer = sfDataGrid1.CurrentCell.RowIndex
Dim c As Integer = sfDataGrid1.CurrentCell.ColumnIndex
Dim FieldName As String = sfDataGrid1.CurrentCell.Column.ToString()
Dim EXTERNAL_NUMBER As String = String.Empty
If Not sfDataGrid1.IsAddNewRowIndex(r) Then
Return
End If
If Not sfDataGrid1.View.IsAddingNew Then
Me.sfDataGrid1.CurrentCell.BeginEdit()
Me.sfDataGrid1.CurrentCell.EndEdit()
End If
Select Case FieldName
Case "CustomerName"
e.KeyPressEventArgs.Handled = True
'--- Fill the Part Number cell with data
Dim rci As New RowColumnIndex(r, c)
sfDataGrid1.View.GetPropertyAccessProvider().SetValue(sfDataGrid1.GetRecordAtRowIndex(rci.RowIndex), sfDataGrid1.Columns(FieldName).MappingName,Value)
'--- THE ABOVE STATEMENT GENERATES A NULL REFERENCE EXCEPTION EVERY TIME
sfDataGrid1.MoveToCurrentCell(rci)
Case "Status"
e.KeyPressEventArgs.Handled = True
'--- Fill the Part Number cell with data
Dim rci1 As New RowColumnIndex(r, c)
sfDataGrid1.View.GetPropertyAccessProvider().SetValue(sfDataGrid1.GetRecordAtRowIndex(rci1.RowIndex), sfDataGrid1.Columns(FieldName).MappingName, Value1)
'--- THE ABOVE STATEMENT GENERATES A NULL REFERENCE EXCEPTION EVERY TIME
sfDataGrid1.MoveToCurrentCell(rci1)
Case Else
Return
End Select
End Sub |