Question:
How can I expose the ItemData property of a ListBox to use it for storing longint data that corresponds to each item in the list in Delphi 3.0? I looked in the windows.pas unit and saw that it was a protected property. Is there a way to make it a usable?
Thanks greatly,
Seth Weiner
Answer:
As with all protected properties, you can expose ItemData through inheritance. Just move the property declaration down to the public or published sections of the type declaration of your descendant.
The code below show how this is done:
unit EnhListBox;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TEnhListBox = class(TListBox) private { Private declarations } protected { Protected declarations } public property ItemData; published { Published declarations } end;procedure Register;implementationprocedure Register;begin RegisterComponents('Samples', [TEnhListBox]);end;end.
Now, whether or not it will actually work remains to be seen. You’ll have to test it out yourself.