diff --git a/lcl/grids.pas b/lcl/grids.pas index b32c09676f..b729446749 100644 --- a/lcl/grids.pas +++ b/lcl/grids.pas @@ -4633,7 +4633,10 @@ begin if (Index>=0) and (Index=ColCount) or (Offset>GridWidth-1) then begin - Index := ColCount-1; + if AllowOutboundEvents then + Index := ColCount-1 + else + Index := -1; exit; end; end; @@ -4652,7 +4655,10 @@ begin if (Index>=0) and (Index=RowCount) or (Offset>GridHeight-1) then begin - Index:=RowCount-1; + if AllowOutboundEvents then + Index := RowCount-1 + else + Index := -1; Exit; // Out of Range end; end; @@ -5705,7 +5711,13 @@ var begin // Do not raise Exception if out of range OffsetToColRow(True, True, X, ACol, dummy); - OffsetToColRow(False,True, Y, ARow, dummy); + if ACol<0 then + ARow := -1 + else begin + OffsetToColRow(False,True, Y, ARow, dummy); + if ARow<0 then + ACol := -1; + end; end; { Convert a fisical Mouse coordinate into a logical cell coordinate }