In TBGrid for coding purposes, would like to know where cursor is. lazarus / 16-Databases ---------------------------------------------------------------------- Elmug · 2012-06-20 06:06 Hi everyone, On a TDBGrid object that is showing the data of a table, as the different fields in the grid are focused, by jumping from field to field (by mouse or keyboard), for program code, I would like to know which field is focused at a given time. Basically, would like to know the name of the column, in which the cursor is  as one moves along in the grid fields. For instance, if the table row has columns (Id, Description, Price) showing in the grid, and the cursor is current at the Description field, I would like to know the name of the column being accessed, if possible, in this case, it would be "Description". If possible, maybe could implement some dynamic DBedit box. Is that possible? If so how? Thanks! ---------------------------------------------------------------------- Zoran · 2012-06-20 07:48 Use DBGrid's OnColEnter event and SelectedColumn property: Code: [Select]procedure TForm1.DBGrid1ColEnter(Sender: TObject); begin   Writeln('col. ' + DBGrid1.SelectedColumn.FieldName + ' entered'); end; ---------------------------------------------------------------------- Elmug · 2012-06-20 09:49 Thanks, Zoran! I think this should work. What you showed I see can have even more uses than what I was after. ---------------------------------------------------------------------- Elmug · 2012-06-20 19:00 Hi everyone, Just to let you all know that Zoran's suggestion worked to help me do exactly what I was after: To have the TDBGrid, by default, be readonly mode, and to have A SINGLE, dynamic TBEdit box that allows edit of the data of the current grid value. I also added a dynamic label that describes the TBEdit's contents. The code was as follows: Used DBGrid's OnColEnter event to trigger this method: procedure TForm1.DBGrid1ColEnter(Sender: TObject); begin   DBEdit1.Datafield := DBGrid1.SelectedColumn.FieldName;   L_EditHere.Caption := DBGrid1.SelectedColumn.FieldName + ':'; end;    Thanks again!