procedure TJvDBGrid.CalcSizingState(X, Y: Integer; var State: TGridState; var Index: Longint; var SizingPos, SizingOfs: Integer; var FixedInfo: TGridDrawInfo); var Coord: TGridCoord; DrawInfo: TGridDrawInfo; begin inherited CalcSizingState(X, Y, State, Index, SizingPos, SizingOfs, FixedInfo); // do nothing if not authorized to size columns if not (dgColumnResize in Options) and not (csDesigning in ComponentState) then Exit; FCanResizeColumn := State = gsColSizing; // If true, mouse double clicking can resize column. { Mantis 5818: Index-out-of-range error when there is only one visible column partially displayed } CalcDrawInfo(DrawInfo); if (DrawInfo.Horz.FullVisBoundary = DrawInfo.Horz.FixedBoundary) then begin Index := Index - 1; // Index from inherited code has the value of 2. end; { Store the column index to resize } if dgIndicator in Options then FResizeColumnIndex := Index - 1 else FResizeColumnIndex := Index; // Mantis 6061 if (State = gsNormal) and (Y <= RowHeights[0]) then begin Coord := MouseCoord(X, Y); CalcDrawInfo(FixedInfo); if CellRect(Coord.X, 0).Right - 5 < X then begin State := gsColSizing; Index := Coord.X; SizingPos := X; SizingOfs := X - CellRect(Coord.X, 0).Right; end; if CellRect(Coord.X, 0).Left + 5 > X then begin State := gsColSizing; Index := Coord.X - 1; SizingPos := X; SizingOfs := X - CellRect(Coord.X, 0).Left; end; if Index <= Byte(dgIndicator in Options) - 1 then State := gsNormal; end; FSizingIndex := Index; FSizingOfs := SizingOfs; end;