Wo ist das Pronlem?
Listbox1.Items.Count dürfte dir doch was sagen oder?
Delphi-Quellcode:
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
i : Integer;
begin
for i := 0 to Listbox1.Items.Count do
begin
if Index mod 2 = 0 then
begin
Listbox1.Canvas.Brush.Color := clRed;
Listbox1.Canvas.FillRect(Rect);
Listbox1.Canvas.TextOut(Rect.Left, Rect.Top, Listbox1.Items[Index]);
end
else
Listbox1.Canvas.TextOut(Rect.Left, Rect.Top, Listbox1.Items[Index]);
end;
end;