在ListBox的Item左边从上到下显示序号1,2,3....N

来源:互联网 发布:c语言getch函数 编辑:程序博客网 时间:2024/05/23 01:53

在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

 点击这里给我发消息
原创粉丝点击