indexing - VB.NET Index '0' is out of range? -


i made listbox in wpf itemsource , classes , events make ui refresh it. there's problem in remove method:

public sub remove(itemindex integer)
mylist.removeat(itemindex)
raiseevent collectionchanged(me, new notifycollectionchangedeventargs(notifycollectionchangedaction.remove, mylist(itemindex)))
end sub

but when execute message index (in case itemindex) out of range. in output window says index '0' (otherwise remove item mylist).

problem solved! changed code

public sub remove(itemindex integer)
mylist.removeat(itemindex)
raiseevent collectionchanged(me, new notifycollectionchangedeventargs(notifycollectionchangedaction.remove, mylist(itemindex)))
end sub

into

public sub remove(itemindex integer)
raiseevent collectionchanged(me, new notifycollectionchangedeventargs(notifycollectionchangedaction.remove, mylist(itemindex), itemindex))
mylist.removeat(itemindex)
end sub

that's all.


Comments