将listbox的style属性设为owndraw就行了
下面的例子在奇数行画线,偶数行输出文本。
procedure TForm1.ListBox1DrawItem(Control: TWinControl;
Index: Integer;
Rect: TRect;
State: TOwnerDrawState);
begin
if Index mod 2 =0 then
begin
ListBox1.Canvas.MoveTo(rect.Left,rect.top);
ListBox1.Canvas.LineTo(rect.right,rect.Bottom);
end else
listbox1.Canvas.TextRect(rect,rect.left,rect.top,ListBox1.Items[index]);
end;