Question

I have a collection object that implements IList. Inside the collection I have used a List to collect the items. Inside the PropertyGrid (at runtime), it binds properly and the Collection Editor opens. I can edit, and I can add items properly and I can catch these methods when they are used in the collection class.

However, if you try to remove any items, they get removed from the collection, but neither IList.Remove or IList.RemoveAt are seemingly used from my Collection. The items deleted are also meant to be deleted from a database, behaviour I implement in the Remove methods.

I also removed all the logic from the remove methods and left them with throw new NotImplmented(), and these don't get fired at all!

I also have an implemented by own CollectionEditor, but still can't see a way to hook into my objects.

So, where should I be looking to find the relevant methods? do I need to change the behaviour of my items as well?

Was it helpful?

Solution

The Collection Editor doesn't use Remove or RemoveAt. Instead, when the user presses the OK button, it calls the IList.Clear method and then calls IList.Add to add all the items the collection will contain. Not that it works with the non-generic version of IList.

OTHER TIPS

Well, Rats!

Inside my CollectionEditor is there any way to get hold of the actual collection? I think I'll get the collection, and then compare it once OK has been pressed, and delete the records from there.

failing that, dust off the matrix screen saver, dig out a good book and tell everyone it's compiling.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top