add a comment to cells in all (visible and non visible) rows

Good morning,
I have a grid with m columns (all visible) and n rows (only some visible) filled with data. Some fields are too small to display the entire content, so I want to add a comment to these cells.
row := 1; // first row is Header
while ....
for col := 0 to m - 1 do
Grid.Cells[col,row] :=
xyCell := Grid.GetCellObject((MakeCell(col,row)));
if xyCell <> nil then
textw := Grid.Canvas.TextWidth(Grid.Cells[col, row]);
colw := Grid.ColumnWidths[col];
if textw > colw then
Grid.Comments[col,row] := ;
It looks like xyCell=nil for non-visible rows.

  1. How can I add a comment to all cells, even the non-visible ones?
  2. If only visible cells can be commented, how can I do this when the vertical scrollbar is moved?
  3. The calculation of the actual text width of a string in a cell and the comparison with the column width does not work reliably.

Thank you for help.


To access hidden cells, you need to use TMSFNCGrid1.DisplToRealRow which will then give the correct index.