DBGrid get selected cell

Remus Rigo picture Remus Rigo · Nov 30, 2009 · Viewed 54.4k times · Source

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.

Answer

Remus Rigo picture Remus Rigo · Nov 30, 2009

Found it.

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