I am trying to find a general way to notify the user interface of changes in the list. For example, when an object is added to the list, I want it to be automatically added to the list. If an object is removed from the list, I want it to be automatically removed from the list.
Unfortunately, there are some crazy inconsistencies between the Delphi lists: TList <>. The notification is great, but TStringList.OnChange doesn't even tell you what the change is, and TList doesn't even have any notification!
I was hoping LiveBindings would provide me with the right way to monitor changes on most lists, but so far I haven't seen it. All the examples I've seen populate a control and establish bindings between list items and controls (list items in my example). But adding / removing an object from the list does not affect the control at all.
Does anyone know of a mechanism that I missed, or is there usually a good general way to do this?
Clarification: It seems that I was not clear enough before. The reason I need a general way is because I wrote a grid control that can connect to various sources, including some existing code. I wrote an interface that the grid accepts as a source, and then several adapter classes to accept some lists and make them available as that interface. Since I also needed to accept the existing code, overriding TList.Notify is not an option. And since there is no event to see the changes, this actually means that TList does not have a notification mechanism that the client can use, for example, my adapter class. TStrings also have none, but TStringList calls a simple OnChange, which means that the adapter class cannot actually determine what has changed.
I really had a very nice solution that used TVirtualMethodInterceptor , but completely stopped working in Delphi XE and was not fixed in XE2.
Cobus kruger
source share