...display an alternating colors for each TCombobox item?

Author: Manfred Hausen
Homepage: http://www.hama-soft.de

Category: Misc

procedure ComboColor(C: TWinControl; I : Integer; R : TRect; EColor, OColor, FColor : TColor);
begin
 with 
(C as TCombobox) do    //TCombobox oder T.....box
   
begin
     if 
Odd(I) then Canvas.Brush.color := OColor
                   else Canvas.Brush.color := EColor;
     Canvas.FillRect(R);
     Canvas.Font.Color := FColor;
     Canvas.TextOut(R.Left,R.Top,Items[I]);
   end;
end;

procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  
ComboColor(Control, Index, Rect, clInfoBk, clWhite, clBlack);
end;

//Combobox.Style := csOwnerDrawFixed;

 

printed from
www.swissdelphicenter.ch
developers knowledge base