Использовать разные цвета для каждого элемента TComboBox



Оформил: DeeCo

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; 

Copyright © 2004-2025 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте