procedure TfrmCatalogos.StringGrid1DblClick(Sender: TObject);
var
rAnt: TRect;
oMousePt: TPoint;
nRow, nCol, nWidth, nWidthMax: Integer;
begin
oMousePt := Mouse.CursorPos;
oMousePt := StringGrid1.ScreenToClient(oMousePt);
for nCol := 1 to StringGrid1.ColCount - 1 do
begin
rAnt := StringGrid1.CellRect(nCol,0);
if (oMousePt.X >= rAnt.Right - 3) and
(oMousePt.X <= rAnt.Right + 4) and
(oMousePt.Y in [rAnt.Top..rAnt.Bottom]) then
begin
nWidthMax := 0;
for nRow := 0 to (StringGrid1.RowCount - 1) do begin
if nRow = 0 then StringGrid1.Canvas.Font.Style := [fsBold]
else StringGrid1.Canvas.Font.Style := [];
nWidth := StringGrid1.Canvas.TextWidth(StringGrid1.Cells[nCol, nRow]);
if nWidth > nWidthMax then
nWidthMax := nWidth;
end;
StringGrid1.ColWidths[nCol] := nWidthMax + 5;
end;
end;
end;