Dear Sir
Why does a DataGridView row disappear when I first make empty in a particular column.
I tried according to your recommendation but there is an error 'Additional information: Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function.'
Protected Sub updateDataSource()
BindingSource1 = New BindingSource With {.DataSource = New BindingList(Of Products)}
'error below line code ` Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function`
DataGridView1.DataSource = BindingSource1
DataGridView1.AutoGenerateColumns = False
DataGridView1.AllowUserToAddRows = False
DataGridView1.Columns("PRICE").DefaultCellStyle.Format = "c2"
DataGridView1.Columns("PRICE").DefaultCellStyle.FormatProvider = CultureInfo.GetCultureInfo("en-US")
DataGridView1.Columns("TOTAL").DefaultCellStyle.Format = "c2"
DataGridView1.Columns("TOTAL").DefaultCellStyle.FormatProvider = CultureInfo.GetCultureInfo("en-US")
BindingSource1.AddNew()
End Sub
Private Sub DataGridView1_DataError(sender As Object, e As DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError
If e.Context = DataGridViewDataErrorContexts.Commit Then
MessageBox.Show(String.Format("value is required.", e.ColumnIndex))
UpdateDataSource()
End If
End Sub