Hi all,
I've a really serious problem,
I've a DataGridView control bounded to a custom entity collection that implements IListSource interface
AND
I've a Data Browser form that contains a grid full of data from a specific table and this form is shown as a dialog from the previous form
When the user clicks Ok button, the selected rows from the browser grid should be added to the Grid on the caller form
So
I perform a For-Loop operation on selected rows to add them to the grid using this code
For Each row As DataBrowserRow In frm.SelectedRows
Me.NotifyCurrentCellDirty(True)
If Me.DataSource IsNot Nothing AndAlso TypeOf Me.DataSource Is EntityCollectionBase Then
Dim ds As EntityCollectionBase = CType(Me.DataSource, EntityCollectionBase)
Dim entity As EntityBase = ds.CreateNewItem
ds.Add(entity)
Me.CurrentCell = Me.Rows(Me.Rows.Count - 1).Cells(browser.TargetColumn)
End If
Next
This code raises the error:
Operation is not valid due to the current state of the object.
Stack trace:
at System.Windows.Forms.DataGridView.DataGridViewDataConnection.ProcessListChanged(ListChangedEventArgs e)
at System.Windows.Forms.DataGridView.DataGridViewDataConnection.currencyManager_ListChanged(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.FireListChanged(ListChangedType type, Int32 index)
at System.ComponentModel.BindingList`1.InsertItem(Int32 index, T item)
at System.Collections.ObjectModel.Collection`1.Add(T item)
at BusinessLogicLayer.EntityCollectionBase`1.Add(EntityBase item)
=================================
I need to add a new row to the data grid anyway possible
Please this is an urgent issue, I hope to get help ASAP