Provide an OnChange event for an internal property which is controlled externally?
- by NGLN
For fun and by request I am updating this ImageGrid component, a kind of listbox for images that has a FileNames property of type TStrings.
For ease of writing, I have been misusing its FileNames.Objects property for bitmap storage. But since the TStrings type suggests that users of the component could or would want to use the Objects property for custom data, e.g. like TListBox.Items, I am rewriting the component to store the bitmaps elsewhere and leave FileNames.Objects untouched for unknown future usage.
Now I am wondering whether to provide an OnChange event. And if so, whether to fire it when one or more FileNames.Objects changes.
Trying to answer it myself, I dove in Delphi's own VCL and stumbled on:
TMemo: has an OnChange event, but ignores Lines.Objects
TListBox: has no OnChange event, but is capable of storing Items.Objects
TStringGrid: has no OnChange event, but is capable of storing Objects, Rows.Objects, Cols.Objects
So now I am somewhat puzzeled, because I cannot imagine Borland's developers didn't add events for several Objects properties out of ease. Sure, when a user changes a FileNames.Object in my component, he knows he does and could implement appropriate interaction himself. But wouldn't it be convenient when the component does automatically?
What would you expect from this component in this regard?