ورود

View Full Version : تغییر رنگ Item در ComboBox



Reza_kh
پنج شنبه 17 فروردین 1385, 17:39 عصر
کدی رو می خوام که با کلیک روی یک دکمه رنگ فقط یکی از Item های ComboBox1 عوض بشه؟ مثلاً قرمز بشه؟!

AlirezaBahredar
یک شنبه 20 فروردین 1385, 16:30 عصر
این کد ببین فکر کنم بد نباشه
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;
در ضمن بگم این کد از سایت Torry
برداشته شده