If I manipulate dgv too much (ie resize, scroll through the added results) while it's still adding, I'll get several of these errors:
Private Delegate sub AddEntryToTableCallback(Byval Entry as SearchResultEntry) Private Sub bwWorker_DoWork(ByVal sender as Object, ByVal e as DoWorkEventArgs) Handles bwWorker.DoWork Dim AddEntry As New AddEntryToTableCallback(AddressOf AddEntryToTable) '... '.... Some worker code here...' '... While True For Each entry as SearchResultEntry in Response.Entries AddEntry.Invoke(entry) Next End While End Sub Private Sub AddEntryToTable(ByVal Entry as SearchResultEntry) Dim tmpDataRow as DataRow = dtMain.NewRow '..Assign values to datarow....' dtMain.Rows.Add(tmpDataRow) dtMain.AcceptChanges() if Me.InvokeRequired Then Me.BeginInvoke(New MethodInvoker(AddressOf RefreshDisplay)) Else RefreshDisplay() End If End Sub Private Sub RefreshDisplay() If me.InvokeRequired Then me.Invoke(New MethodInvoker(AddressOf dgv.Refresh)) Else dgv.Refresh End If End Sub
It isn't exactly clear where this is getting thrown and I've tried adding a catch for the DataError Event, but I can't Isolate it. The error doesn't seem to hinder the results from continuing to be added. Nor does the error occur at any time after all rows have been added.
DataGridView Default Error Dialog The following exception occured in the DataGridView: System.InvalidOperationException: BindingSource cannot be its own data source. Do not set the DataSource and Datamember Properties to values that refer back to the BindingSource. at System.Windows.Forms.BindingSource.get_Count() at System.Windows.Forms.CurrencyManager.get_Item(Int32_index) at System.Windows.Forms.DataGridView.DataGridViewDataConnection.GetError(Int32 boundColumnIndex, Int32 columnIndex, Int32 rowIndex) To replace this default dialog please handle the DataError Event.
Do more with