首先设置:listbox1.stype:=lbOwnerDrawFixed;
然后在listbox1的事件DrawItem如下:
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
with ListBox1.Canvas do
begin
if index mod 2 = 1 then
begin
Font.Color:=clred;
Brush.Color:=clBlue;
end else
begin
Font.Color:=clBlue;
Brush.Color:=clred;
end;
FillRect(Rect);
TextOut(Rect.Left, Rect.Top, listbox1.Items[index]);
end;
end;
关于保存的问题我想你可以根据Index,用数组等保存都很容易的.