To reproduce:
1. Add a RadGridView and bind it to Northwind.Products table.
2. Use the following code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products)
For Each col As GridViewColumn In Me.RadGridView1.Columns
If Not col.HeaderText = "SupplierID" AndAlso Not col.HeaderText = "ProductID" Then
col.ReadOnly = True
End If
Next
Me.RadGridView1.AddNewRowPosition = SystemRowPosition.Bottom
End Sub
Private Sub RadGridView1_CellValidating(sender As Object, e As CellValidatingEventArgs) Handles RadGridView1.CellValidating
If e.Value Is Nothing Then
If MessageBox.Show("Incorrect", "error", MessageBoxButtons.OKCancel) = Windows.Forms.DialogResult.OK Then
e.Cancel = True
End If
End If
End Sub
3. Run the project and go to the new row ,cell "SupplierID".
4. Clear the value and press Tab key. As a result the message box for error indication is shown twice.
Workaround:
'register the custom row behavior
Dim gridBehavior As BaseGridBehavior = TryCast(RadGridView1.GridBehavior, BaseGridBehavior)
gridBehavior.UnregisterBehavior(GetType(GridViewNewRowInfo))
gridBehavior.RegisterBehavior(GetType(GridViewNewRowInfo), New MyNewRowBehavior())
Me.RadGridView1.GridViewElement.Navigator = New MyGridNavigator()
Public Class MyNewRowBehavior
Inherits GridNewRowBehavior
Protected Overrides Function ProcessTabKey(keys As KeyEventArgs) As Boolean
If Me.GridControl.AddNewRowPosition = SystemRowPosition.Bottom AndAlso _
Me.GridControl.IsInEditMode AndAlso Me.GridViewElement.Navigator.IsLastColumn(GridViewElement.CurrentColumn) Then
Me.GridControl.Tag = "SuspendValidation"
End If
Return MyBase.ProcessTabKey(keys)
End Function
End Class
Public Class MyGridNavigator
Inherits BaseGridNavigator
Public Overrides Function SelectFirstColumn() As Boolean
If Me.GridViewElement.GridControl.Tag = "SuspendValidation" Then
Me.GridViewElement.GridControl.Tag = Nothing
Return False
End If
Return MyBase.SelectFirstColumn()
End Function
End Class