Microsoft
Software
Hardware
Network
Question : BindingList(Of T) generate exception when replacing items
Hi experts,
I use BindingList(Of T) and when i want to replace a specific item in the list, i have an exception :
The list must be an IBindingList to AddNew
Here is the StackTrace :
at System.Windows.Forms.Curre
ncyManager
.AddNew()
at System.Windows.Forms.Relat
edCurrency
Manager.Pa
rentManage
r_CurrentI
temChanged
(Object sender, EventArgs e)
at System.EventHandler.Invoke
(Object sender, EventArgs e)
at System.Windows.Forms.Curre
ncyManager
.OnCurrent
ItemChange
d(EventArg
s e)
at System.Windows.Forms.Relat
edCurrency
Manager.Pa
rentManage
r_CurrentI
temChanged
(Object sender, EventArgs e)
at System.EventHandler.Invoke
(Object sender, EventArgs e)
at System.Windows.Forms.Curre
ncyManager
.OnCurrent
ItemChange
d(EventArg
s e)
at System.Windows.Forms.Curre
ncyManager
.List_List
Changed(Ob
ject sender, ListChangedEventArgs e)
at System.ComponentModel.List
ChangedEve
ntHandler.
Invoke(Obj
ect sender, ListChangedEventArgs e)
at System.ComponentModel.Bind
ingList`1.
OnListChan
ged(ListCh
angedEvent
Args e)
at System.ComponentModel.Bind
ingList`1.
FireListCh
anged(List
ChangedTyp
e type, Int32 index)
at System.ComponentModel.Bind
ingList`1.
SetItem(In
t32 index, T item)
at System.Collections.ObjectM
odel.Colle
ction`1.se
t_Item(Int
32 index, T value)
I don't understand why because is some case, it works...
Thank you,
Regards.
1:
Me.DataSource.Item(index) = lRestoreMonitorDesign
Answer : BindingList(Of T) generate exception when replacing items
Dude are you trying to replace the object at ith position?
If yes, then you should better take that object@ith index into some object and work upon it.
binding list lets you upate/add/delete the object but you can't replace the object reference altogther
For doing this remove the requirec object and add a new one.
This is exactly the error says "The list must be an IBindingList to AddNew"
hope this helps :)
Random Solutions
datagridview cell click of null value
How do I write data to separate excel worksheets in coldfusion?
Check null integer
Exchange 2003 Logical Size vs Physical Size
Cisco VPN client for Windows, use both RSA SecurID soft token and hard token
Crystal Reports Xi - Sorting a CrossTab Report by a Summary Field
Is there a tool to check to see who has enabled auto-forward in outlook
Unable to change my network card speed from 10 MB after creating a vm of Windows XP Pro
help with differential equation (but algebra reall)
sql query help