Create a Column Showing the Row Index - FireMonkey Guide

Back to FireMonkey Topics

Here’s a simple tip to create a grid column which displays the row index.

First, add a TGrid to your form. Double click the grid to open the items editor and add a column of type TColumn. Now add an event handler for OnGetValue,

procedure TForm1.Grid1GetValue(SenderTObject; const ColRowInteger;
  var 
ValueTValue);
begin
  
if Col 0 then
    Value 
:= TValue.From<String>(IntToStr(Row+1));
end

I’ve added one to the row number to get 1-based indexing.

See Also

TGrid

Categories:

div title=