Webstringgrid auto size

How can I auto size the rows and columns to fit the text please.

I found this VCL code

procedure TForm7.AutoSizeColumns(Grid: TStringGrid);
var
  i, j: Integer;
  ColumnWidth: Integer;
begin
  for j := 0 to Grid.ColCount - 1 do
  begin
    ColumnWidth := Round(Grid.Canvas.TextWidth(Grid.Cells[j, 0]));
    for i := 1 to Grid.RowCount - 1 do
    begin
      if Round(Grid.Canvas.TextWidth(Grid.Cells[j, i])) > ColumnWidth then
        ColumnWidth := Round(Grid.Canvas.TextWidth(Grid.Cells[j, i]));
    end;
    Grid.ColWidths[j] := ColumnWidth + 10; // Adding some padding
  end;
end;

I get ERROR
Uncaught TypeError: Cannot read properties of null (reading 'TextWidth') | TypeError: Cannot read properties of null (reading 'TextWidth') at Object.AutoSizeColumns

On WebResponsiveGridPanel3LayoutChange can I get the number of Columns or if fr1 Or fr1 fr1

so I can use

        WebStringGridRates.ColWidths[0] := Round(WebResponsiveGridPanel3.Width / 3) ;
        WebStringGridRates.ColWidths[1] := Round(WebResponsiveGridPanel3.Width / 3) ;
        WebStringGridRates.ColWidths[2] := Round(WebResponsiveGridPanel3.Width / 3) ;

A TWebStringGrid isn't rendered through a canvas but through HTML tables.
As such the canvas cannot be used.
If you want auto sizing columns, we'd recommend to use a TWebTableControl. The columns will adopt the width of the largest text.