Delphi TStringGrid is displayed incorrectly (with unwanted column spacing) in Embracedero Delphi 10.4. I tried everything in settings - disabled margins, disable Ctl3D, font settings, ... - I also tried creating a totally new StringGrid, but there is still a problem with column spacing.
Code to reproduce:
procedure TForm5.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if ARow = 0 then
begin
StringGrid1.Canvas.Brush.Color := $808080;
StringGrid1.Canvas.FillRect(Rect)
end;
end;

It is a known issue that the cell's
Rect.Leftin theOnDrawCellevent of aTStringGridis offset by 4 pixels. Probably (but not documented) to make it more easy to output text data, which requires a small offset from the border of the cell.Note that the
TDrawGriddoes not have this offset.For background painting of a cell you can use the
CellRect()function