2

I'm making a Scheduling System and I want to color some specific Items in the List View. For example, if the current time in the clock is 07:00 AM then the list view would color all the items that has 07:00 AM in it. How would I do this? I really don't know where to start. What i have right now is this,

View Schedule View Schedule

Tomasz Jakub Rup
  • 10,502
  • 7
  • 48
  • 49
Rei ReiChel
  • 21
  • 1
  • 3

1 Answers1

3

You can set the font properties in OnCustomDrawItem and OnCustomDrawSubItem event handlers. For instance:

procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView; Item: TListItem;
  State: TCustomDrawState; var DefaultDraw: Boolean);
begin
  if odd(Item.Index) then begin
    Sender.Canvas.Font.Color := clRed;
  end;
end;

procedure TForm1.ListView1CustomDrawSubItem(Sender: TCustomListView; Item: TListItem; 
  SubItem: Integer; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
  if odd(Item.Index) then begin
    Sender.Canvas.Font.Color := clRed;
  end;
end;
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490