Автоматический подбор ширины колонок для TStringGrid 2
Оформил: DeeCo
Автор: http://www.swissdelphicenter.ch
procedure TForm1.Button1Click(Sender: TObject);
{ by P. Below }
const
DEFBORDER = 8;
var
max, temp, i, n: Integer;
begin
with Grid do
begin
Canvas.Font := Font;
for n := Low(Columns) to High(Columns) do
begin
max := 0;
for i := 0 to RowCount - 1 do
begin
temp := Canvas.TextWidth(Cells[Columns[n], i]) + DEFBORDER;
if temp > max then
max := temp;
end; { For }
if max > 0 then
ColWidths[Columns[n]] := max;
end; { For }
end; { With }
end; {SetGridColumnWidths }
|