Home > Enterprise >  Delphi - How can I change a single item Backgroundcolor in a TControlList
Delphi - How can I change a single item Backgroundcolor in a TControlList

Time:08-02

I try to get that white/grey pattern with the TControlList but was not able to find the right Property. ItemColor changes the backgroundcolor of every Item and Color itself changes Background for the complet control.

I had tried to manipulate the aCanvas object inside the OnBeforeDrawItem Event but that doesn't work either. Inside the documentation is loud silence.

Can anyone help with that?

CodePudding user response:

You don't have to use canvas only set itemcolor

procedure TForm1.ControlList1BeforeDrawItem(AIndex: Integer; ACanvas: TCanvas;
  ARect: TRect; AState: TOwnerDrawState);
begin
if Odd(aIndex)
  then ControlList1.ItemColor:=clWhite
  else ControlList1.ItemColor:=clLtGray;
end;

alternate rows for TControlList

  • Related