Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: ListView change individual ListViewItem properties


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Jun 30, 2014 11:31 AM Last Post By: brent shelton
brent shelton

Posts: 29
Registered: 2/14/09
ListView change individual ListViewItem properties  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 30, 2014 9:32 AM
Is there a way to change each ListViewItem property separately like the color? I tried the UpdateObjects event but it changes all of them to the same color:

procedure TfrmMain.MyListViewUpdateObjects(const Sender: TObject;
const AItem: TListViewItem);
begin
if Pos(AItem.Detail, '1000.00') <> 0 then
AItem.Objects.DetailObject.TextColor := TAlphaColorRec.Blue
else
AItem.Objects.DetailObject.TextColor := TAlphaColorRec.Red;
end;
brent shelton

Posts: 29
Registered: 2/14/09
Re: ListView change individual ListViewItem properties  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 30, 2014 11:31 AM   in response to: brent shelton in response to: brent shelton
I figured it out. I just put it in the same event where I populate the ListView:

with MyListView.Items.Add do begin
Detail := Format('%f', [MyTable.FieldByName('Amount').AsFloat]);
if Detail = '-1000.00' then
Objects.DetailObject.TextColor := TAlphaColorRec.Red
else
Objects.DetailObject.TextColor := TAlphaColorRec.Blue;
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02