var
i, MaxWidth: integer;
begin
MaxWidth := 0;
for i := 0 to ListBox1.Items.Count - 1do
if MaxWidth < ListBox1.Canvas.TextWidth(ListBox1.Items.Strings) then
MaxWidth := ListBox1.Canvas.TextWidth(ListBox1.Items.Strings);
SendMessage(ListBox1.Handle, LB_SETHORIZONTALEXTENT, MaxWidth+150, 0);
end;
或者继承TListBox写一个
看看这里,改一下就行了
http://www.delphibbs.com/delphibbs/dispq.asp?lid=691355