ListBoxes and ItemData

ListBoxes and ItemData

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

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.

See also  How IoT Tech Will Transform Logistics

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist