Search code examples
delphidbgrid

DBGrid get selected cell


I need to get the value of the selected cell of a DBGrid in Delphi.

I have no idea how to do it. I tried dbGrid's OnMouseMove

pt : TGridCoord;
...
pt:=dbGrid.MouseCoord(x, y);

[Edited] I can use the OnCellClick to get the value of the cell with "Column.Field.AsString", but I want to get the value from the first column when I click on any column of that row.


Solution

  • Found it.

    dbGrid.Fields[0].AsString gets the value of the first column of the selected row.