Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uses
- Math;
- type
- TStringGrid = class(Vcl.Grids.TStringGrid)
- protected
- procedure SelectionMoved(const OldSel: TGridRect); override;
- end;
- implementation
- { TStringGrid }
- procedure TStringGrid.SelectionMoved(const OldSel: TGridRect);
- var
- I: Integer;
- begin
- // invalidate selection changes
- inherited;
- // invalidate all the fixed columns
- for I := 0 to FixedCols - 1 do
- InvalidateCol(I);
- // invalidate all the fixed rows
- for I := 0 to FixedRows - 1 do
- InvalidateRow(I);
- end;
- procedure TForm1.StringGridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
- var
- Grid: TStringGrid;
- begin
- Grid := TStringGrid(Sender);
- if (gdFixed in State) and (InRange(ARow, Grid.Selection.Top, Grid.Selection.Bottom) or
- InRange(ACol, Grid.Selection.Left, Grid.Selection.Right))
- then
- Grid.Canvas.Brush.Color:= $00FFDE9B
- else
- Grid.Canvas.Brush.Color := clwhite;
- Grid.Canvas.FillRect(Rect);
- Grid.Canvas.TextOut(0, Rect.Top + 4, Grid.Cells[ACol, ARow]);
- if gdSelected in State then
- Grid.Canvas.DrawFocusRect(Rect);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement