From 40285d1653ac83ff1f9baebe73267d51f7ce256e Mon Sep 17 00:00:00 2001 From: michl Date: Tue, 6 Mar 2018 19:41:20 +0000 Subject: [PATCH] LCL: DBGrid: Fixed pressing RETURN in the last row of the DBGrid the focus stay in the last column. Issue #33294 git-svn-id: trunk@57458 - --- lcl/dbgrids.pas | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lcl/dbgrids.pas b/lcl/dbgrids.pas index ccd7adb04d..0f84d92580 100644 --- a/lcl/dbgrids.pas +++ b/lcl/dbgrids.pas @@ -2381,6 +2381,8 @@ var end; procedure MoveSel(AReset: boolean); + var + ACol: Integer; begin if (DeltaCol<>0) or (DeltaRow<>0) then begin if DeltaRow > 0 then begin @@ -2398,7 +2400,16 @@ var else if Col + DeltaCol >= ColCount then Col := ColCount - 1 else - Col := Col + DeltaCol; + begin + ACol := Col + DeltaCol; + if ColWidths[ACol] > 0 then + Col := ACol + else + if DeltaCol < 0 then + Col := GetFirstVisibleColumn + else + Col := GetLastVisibleColumn; + end; GridFlags := GridFlags - [gfEditingDone]; end else if AReset then