Advertisement
TLama

Untitled

Jul 30th, 2015
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.11 KB | None | 0 0
  1. uses
  2.   Math;
  3.  
  4. type
  5.   TStringGrid = class(Vcl.Grids.TStringGrid)
  6.   protected
  7.     procedure SelectionMoved(const OldSel: TGridRect); override;
  8.   end;
  9.  
  10. implementation
  11.  
  12. { TStringGrid }
  13.  
  14. procedure TStringGrid.SelectionMoved(const OldSel: TGridRect);
  15. var
  16.   I: Integer;
  17. begin
  18.   // invalidate selection changes
  19.   inherited;
  20.   // invalidate all the fixed columns
  21.   for I := 0 to FixedCols - 1 do
  22.     InvalidateCol(I);
  23.   // invalidate all the fixed rows
  24.   for I := 0 to FixedRows - 1 do
  25.     InvalidateRow(I);
  26. end;
  27.  
  28. procedure TForm1.StringGridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
  29. var
  30.   Grid: TStringGrid;
  31. begin
  32.   Grid := TStringGrid(Sender);
  33.  
  34.   if (gdFixed in State) and (InRange(ARow, Grid.Selection.Top, Grid.Selection.Bottom) or
  35.     InRange(ACol, Grid.Selection.Left, Grid.Selection.Right))
  36.   then
  37.     Grid.Canvas.Brush.Color:= $00FFDE9B
  38.   else
  39.     Grid.Canvas.Brush.Color := clwhite;
  40.  
  41.   Grid.Canvas.FillRect(Rect);
  42.   Grid.Canvas.TextOut(0, Rect.Top + 4, Grid.Cells[ACol, ARow]);
  43.  
  44.   if gdSelected in State then
  45.     Grid.Canvas.DrawFocusRect(Rect);
  46. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement