procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  with TListBox(Control), TListBox(Control).Canvas do begin
    FillRect(Rect);
    Font.Color := StringToColor(Items[Index]);
    Canvas.TextOut(Rect.Left, Rect.Top, Items[Index]);
  end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
  ListBox1.Style := lbOwnerDrawVariable;
  ListBox1.Clear;
  ListBox1.Items.Text :=
'clBlack'#13#10 +
'clMaroon'#13#10 +
'clGreen'#13#10 +
'clOlive'#13#10 +
'clNavy'#13#10 +
'clPurple'#13#10 +
'clTeal'#13#10 +
'clGray'#13#10 +
'clSilver'#13#10 +
'clRed'#13#10 +
'clLime'#13#10 +
'clYellow'#13#10 +
'clBlue'#13#10 +
'clFuchsia'#13#10 +
'clAqua'#13#10 +
'clWhite'#13#10;
end;

解决方案 »

  1.   

    To: zswang(伴水)(* pascal→c *) 
    2颗红星的确不同呀,哦,你说要是我实时刷新是不是就是采用我那样的程序呢?
      

  2.   

    to hammer_shi(凤舞九天):如果你的颜色配置是动态的,就在Change中刷新一次就可以了
      

  3.   

    change?那个的change?
    为什么在程序中使用了Refresh却需要手工点击改变颜色的行或者使用
    for i:=0 to Listbox1.Items.Count-1 do
        begin
        ListBox1.ItemIndex:=i;
        end;