Board index » delphi » Data and ListView / ListItems / Listitem

Data and ListView / ListItems / Listitem

Hey,

I dropped a custom object in the data pointer of the listitem.
Everything display well, but How do you acces the pointer or object?

listitem1:=listview1.Items.Add;
listitem1.Caption:=PKSRCDini1.pSRCDitem[int1arrayclassexist]].pname;
listitem1.Data:=PKSRCDini1.pSRCDitem[int1array[classexist]];

Thanks for your help

Patrick Kriech

 

Re:Data and ListView / ListItems / Listitem


Quote
> Hey,

> I dropped a custom object in the data pointer of the listitem.
> Everything display well, but How do you acces the pointer or object?

> listitem1:=listview1.Items.Add;
> listitem1.Caption:=PKSRCDini1.pSRCDitem[int1arrayclassexist]].pname;
> listitem1.Data:=PKSRCDini1.pSRCDitem[int1array[classexist]];

By typecasting the data pointer to your class!

var
  YourVar : TYourVar; // or your objecttype

begin
  if ListItem.data = nil then exit;
  YourVar := TYourVar(ListItem.data)
......

regards
Henrik

Re:Data and ListView / ListItems / Listitem


Quote
"Henrik Nedergaard" <hen...@hn-itservice.dk> wrote:
>> Hey,

>> I dropped a custom object in the data pointer of the listitem.
>> Everything display well, but How do you acces the pointer or object?

>> listitem1:=listview1.Items.Add;
>> listitem1.Caption:=PKSRCDini1.pSRCDitem[int1arrayclassexist]].pname;
>> listitem1.Data:=PKSRCDini1.pSRCDitem[int1array[classexist]];

>By typecasting the data pointer to your class!

>var
>  YourVar : TYourVar; // or your objecttype

>begin
>  if ListItem.data = nil then exit;
>  YourVar := TYourVar(ListItem.data)
>.......

>regards
>Henrik

>Excellent!  Thanks  PK

Other Threads