You can use the mouse coordinates to get the column. After calling TDBGrid.MouseCoord
, the returned TGridCoord.X
contains the column number, and the Y
contains the row (which, of course, you already have):
procedure TForm1.DBGrid1CellClick(Column: TColumn);
var
Pt: TPoint;
Coord: TGridCoord;
ClickCol: Integer;
begin
Pt := DBGrid1.ScreenToClient(Mouse.CursorPos);
Coord := DBGrid1.MouseCoord(Pt.X, Pt.Y);
ClickCol := Coord.X;
ShowMessage('You clicked column ' + IntToStr(ClickCol));
end;
More info on TGridCoord
in the documentation.
Tested using the same app used for my answer to your previous question.