Hi,
i have a windows application.
This application uses a object that its of type collectionbase.
For other hand i have a ListBox, and i use this collection to fill it.
I have implemented the methods (in my class that derives from collection
base):
//to get an element from collection
public type of object Get_(int index)
{
return (type of object) List[index]
}
//to add into collection
public void Add_(type of the object object)
{
List.Add(object)
}
//to remove from collection
public void Remove_(type of the object object)
{
List.Remove(object)
}
I dont know if my steps are correctly:
1) when application loads i fill the collection, and i fill the listbox with
the collection.
2) When a person clicks in a item i get the object from the collection with
the index (ListBox.SelectedIndex)
3) i remove from collection this object that i got in the step 2.
4) i assign the datasource of the listbox to null
5) i remove from the listbox the item selected
6) i assign the datasource of the listbox the collection (with the item
removed in step 3)
When i execute the application, and i delete an item, all goes correctly
except when i delete the last.... In this case (deleting the last item) the
application deletes it, but when i selected another item, i get an Error of
type IndexOutOfRange exception....
Questions:
1) What could be the problem?
2) Its my logic to do this wrong?
3) Generally this kind of stuff are made following this way?
Any advice would be appreciated...
--------
Thanks
Regards.
Josema