Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Pascal
Expertise: Beginner
Jun 15, 1998

ListBoxes and ItemData

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;

interface

uses
  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;

implementation

procedure 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.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date