在ListBox的Item左边从上到下显示序号1,2,3....N
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
with ListBox1.Canvas do
begin
FillRect(Rect);
TextOut(Rect.Left+1, Rect.Top+1,inttostr(Index+1)+ListBox1.Items[Index]);
end;
end;
[说明]需要把ListBox的Style属性设为lbOwnerDrawFixed
