Marc,
Probably - but you can't *fully* verify the cancel conditions (the
index etc) since they aren't available as protected... I added
Console.WriteLi ne to RemoveItem, and it seemed to be working fine...
I found that this occurs only when I move up-down in my
CustomDataGridV iewComBobox column.
Down arrow in this column invokes AddNewCore().
Up arrow does *not* invoke RemoveItem.
Pressing down arrow again causes InvalidOperatio nException in
base.AddNewCore ()
It seems that my combobox column class blocks bindinglist RemoveItem call.
I checked my class overridden methods and it seems that I'm calling base
methods in most cases.
Which combobox columns method calls bindinglist RemoveItem() ?
I implemented combobox column using MSDN sample code.
Any idea how to debug / resolve this issue? Exception which I got is below.
Andrus.
System.InvalidO perationExcepti on was unhandled
Message="Operat ion is not valid due to the current state of the object."
Source="System. Windows.Forms"
StackTrace:
at
System.Windows. Forms.DataGridV iew.DataGridVie wDataConnection .ProcessListCha nged(ListChange dEventArgs
e)
at
System.Windows. Forms.DataGridV iew.DataGridVie wDataConnection .currencyManage r_ListChanged(O bject
sender, ListChangedEven tArgs e)
at
System.Windows. Forms.CurrencyM anager.OnListCh anged(ListChang edEventArgs e)
at System.Windows. Forms.CurrencyM anager.List_Lis tChanged(Object
sender, ListChangedEven tArgs e)
at
System.Componen tModel.BindingL ist`1.OnListCha nged(ListChange dEventArgs e)
at System.Componen tModel.BindingL ist`1.InsertIte m(Int32 index, T
item)
at System.Collecti ons.ObjectModel .Collection`1.A dd(T item)
at System.Componen tModel.BindingL ist`1.AddNewCor e()
at MyAppl.TableLis t`1.AddNewCore( ) in I:\MyAppl\Table List.cs:line 92
at
System.Componen tModel.BindingL ist`1.System.Co mponentModel.IB indingList.AddN ew()
at System.Windows. Forms.CurrencyM anager.AddNew()
at
System.Windows. Forms.DataGridV iew.DataGridVie wDataConnection .AddNew()
at
System.Windows. Forms.DataGridV iew.DataGridVie wDataConnection .OnNewRowNeeded ()
at System.Windows. Forms.DataGridV iew.OnRowEnter( DataGridViewCel l&
dataGridViewCel l, Int32 columnIndex, Int32 rowIndex, Boolean
canCreateNewRow , Boolean validationFailu reOccurred)
at System.Windows. Forms.DataGridV iew.SetCurrentC ellAddressCore( Int32
columnIndex, Int32 rowIndex, Boolean setAnchorCellAd dress, Boolean
validateCurrent Cell, Boolean throughMouseCli ck)
at System.Windows. Forms.DataGridV iew.ProcessDown KeyInternal(Key s
keyData, Boolean& moved)
at System.Windows. Forms.DataGridV iew.ProcessDown Key(Keys keyData)
at
System.Windows. Forms.DataGridV iew.ProcessData GridViewKey(Key EventArgs e)
at System.Windows. Forms.DataGridV iew.ProcessKeyP review(Message& m)
at System.Windows. Forms.Control.P rocessKeyPrevie w(Message& m)
at System.Windows. Forms.Control.P rocessKeyMessag e(Message& m)
at System.Windows. Forms.ComboBox. ChildWndProc(Me ssage& m)
at
System.Windows. Forms.ComboBox. ComboBoxChildNa tiveWindow.WndP roc(Message& m)
at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows. Forms.UnsafeNat iveMethods.Disp atchMessageW(MS G&
msg)
at
....