给分
procedure TForm1.FormCreate(Sender: TObject);
var
  i:integer;
begin
  MaxWidth:=0;
  for i:=1 to 20 do
  begin
    ListBox1.Items.Add('AAAAAAAAAAAAAAAAAAAAAAAAA');
  end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
  i: integer;
begin
  for i := 0 to ListBox1.Items.Count - 1 do
  if MaxWidth < ListBox1.Canvas.TextWidth(ListBox1.Items[i]) then
    MaxWidth := ListBox1.Canvas.TextWidth(ListBox1.Items[i]);
  SendMessage(ListBox1.Handle, LB_SETHORIZONTALEXTENT, MaxWidth+2, 0);
end;