tags:

views:

379

answers:

3

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

(i have no idea how to do it, i tryed 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

+1  A: 

found it

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

Remus Rigo
A: 

A DB grid has no focus, and therefore you cannot find out which row is seleted. Instead look at the linked dataset. A dataset has an active row.

birger
A: 

i think the easiest way is to connect a hidden DBText to your dataset then set the DBText to display which field you need, this way that DBText will always contain the needed value of the active record

Alin Sfetcu