Advertisement
Guest User

Untitled

a guest
Dec 23rd, 2020
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.46 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Grids, Types;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     StringGrid1: TStringGrid;
  16.     procedure FormCreate(Sender: TObject);
  17.     procedure StringGrid1DrawCell(Sender: TObject; aCol, aRow: Integer;
  18.       aRect: TRect; aState: TGridDrawState);
  19.   private
  20.  
  21.   public
  22.  
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.   flag: integer;
  28. implementation
  29.  
  30. {$R *.lfm}
  31.  
  32. { TForm1 }
  33.  
  34. procedure TForm1.FormCreate(Sender: TObject);
  35. var
  36.   i,j:integer;
  37. begin
  38. flag:=0;
  39. with stringGrid1 do
  40.      begin
  41.      colcount:=11;
  42.      rowcount:=11;
  43.      FixedCols:=1;
  44.      FixedRows:=1;
  45.      for i:=1 to colcount-1 do
  46.          begin
  47.          cells[i, 0]:=inttostr(i);
  48.          cells[0, i]:=inttostr(i);
  49.          end;
  50.      for i:=1 to colcount-1 do
  51.          for j:=1 to rowcount-1 do
  52.              cells[i,j]:=inttostr((i)*(j));
  53.      end;
  54. end;
  55.  
  56. procedure TForm1.StringGrid1DrawCell(Sender: TObject; aCol, aRow: Integer;
  57.   aRect: TRect; aState: TGridDrawState);
  58. var
  59.   s:string;
  60. begin
  61.   if ((acol=0) or (arow=0)) and (flag<20) then
  62.      begin
  63.      Stringgrid1.Canvas.Brush.color := RGBTOCOLOR(Random(255), Random(255), Random(255));
  64.      Stringgrid1.Canvas.FillRect(arect);
  65.      Stringgrid1.Cells[acol, arow]:=Stringgrid1.Cells[acol, arow];
  66.      StringGrid1.Canvas.TextOut(aRect.Left+2,aRect.Top+2,StringGrid1.Cells[ACol, ARow]);
  67.      inc(flag);
  68.      end;
  69. end;
  70.  
  71. end.
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement