Cannot Access Grid Cell Values

In the FNCGrid, I cannot get the selected cell values. The Grid is populated with a TMSFNCGridDatabaseAdapter, and all the rows are displayed.

I'm trying to get the value of column 3 for all selected rows like this :

var i : Integer;
ARowIndex : Integer;
for i := 0 to grdAddresses.RowSelectionCount -1 do begin
ARowindex := grdAddresses.SelectedRow[i];
Memo1.Lines.Add(IntToStr(ARowIndex) + ' : ' + grdAddresses.Cells[3, ARowIndex]);

ARowIndex is correctly populated with the selected row ID, but Cells[3, ARowIndex] always returns an empty string, and it doesn't matter which value I use for the Column number it's always blank.

Any ideas ?


When connecting with a grid database adapter, the cell data is not stored, instead it is dynamically retrieved to conserve memory especially when having a lot of records. So to access the data, you can use direct access to the cell using the following code:

grdAddresses.GetCellObject(MakeCell(3, ARowIndex)); which returns a TTMSFNCGridCell object and then the cell object has a property Text to retrieve the value. Note though that this value is only set for the visible rows.

Thanks Pieter, that works.