diff --git a/lcl/dbgrids.pas b/lcl/dbgrids.pas index 060f45baa3..a1aacebf22 100644 --- a/lcl/dbgrids.pas +++ b/lcl/dbgrids.pas @@ -2336,6 +2336,9 @@ var CurActiveRecord: Integer; begin if FDataLink.Active then begin + {$ifdef dbgGridPaint} + DebugLn('DrawAllRows: Link.ActiveRecord=%d, Row=%d',[FDataLink.ActiveRecord, Row]); + {$endif} CurActiveRecord:=FDataLink.ActiveRecord; FDrawingEmptyDataset:=FDatalink.DataSet.IsEmpty; end else @@ -2377,7 +2380,7 @@ begin {$endif} inherited DrawRow(ARow); {$ifdef dbgGridPaint} - DebugLn('End Row') + DebugLn(' End Row') {$endif} end; @@ -2501,6 +2504,7 @@ begin // find out the column count, if result=0 then // there are no visible columns defined or dataset is inactive // or there are no visible fields, ie the grid is blank + {$IfDef dbgDBGrid}DebugLn('TCustomDbgrid.UpdateGridCounts INIT');{$endif} BeginVisualChange; try Result := GetColumnCount; @@ -2528,11 +2532,15 @@ begin RowCount := RecCount; FixedRows := FRCount; FixedCols := FCCount; + UpdateGridColumnSizes; + + SetColRow(Col, FixedRows + FDatalink.ActiveRecord); end; finally EndVisualChange; end; + {$IfDef dbgDBGrid}DebugLn('TCustomDbgrid.UpdateGridCounts END');{$endif} end; procedure TCustomDBGrid.UpdateVertScrollbar(const aVisible: boolean; diff --git a/lcl/grids.pas b/lcl/grids.pas index 53cc84d5af..3294a76abb 100644 --- a/lcl/grids.pas +++ b/lcl/grids.pas @@ -658,7 +658,6 @@ type procedure SetTopRow(const AValue: Integer); procedure TryScrollTo(aCol,aRow: integer); procedure UpdateScrollBarPos(Which: TScrollStyle); - procedure UpdateSelectionRange; procedure WriteColumns(Writer: TWriter); procedure WriteColWidths(Writer: TWriter); procedure WriteRowHeights(Writer: TWriter); @@ -795,6 +794,7 @@ type function SelectCell(ACol, ARow: Integer): Boolean; virtual; procedure SetCanvasFont(aFont: TFont); procedure SetColor(Value: TColor); override; + procedure SetColRow(const ACol,ARow: Integer); procedure SetEditText(ACol, ARow: Longint; const Value: string); dynamic; procedure SetBorderStyle(NewStyle: TBorderStyle); override; procedure SetFixedcolor(const AValue: TColor); virtual; @@ -805,6 +805,7 @@ type function TryMoveSelection(Relative: Boolean; var DCol, DRow: Integer): Boolean; procedure UnLockEditor; procedure UpdateHorzScrollBar(const aVisible: boolean; const aRange,aPage: Integer); virtual; + procedure UpdateSelectionRange; procedure UpdateVertScrollbar(const aVisible: boolean; const aRange,aPage: Integer); virtual; procedure UpdateBorderStyle; procedure VisualChange; virtual; @@ -2677,6 +2678,13 @@ begin inherited SetColor(Value); end; +procedure TCustomGrid.SetColRow(const ACol, ARow: Integer); +begin + FCol := ACol; + FRow := ARow; + UpdateSelectionRange; +end; + procedure TCustomGrid.DrawBorder; var R: TRect;