Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Grids, Types;
- type
- { TForm1 }
- TForm1 = class(TForm)
- StringGrid1: TStringGrid;
- procedure FormCreate(Sender: TObject);
- procedure StringGrid1DrawCell(Sender: TObject; aCol, aRow: Integer;
- aRect: TRect; aState: TGridDrawState);
- private
- public
- end;
- var
- Form1: TForm1;
- flag: integer;
- implementation
- {$R *.lfm}
- { TForm1 }
- procedure TForm1.FormCreate(Sender: TObject);
- var
- i,j:integer;
- begin
- flag:=0;
- with stringGrid1 do
- begin
- colcount:=11;
- rowcount:=11;
- FixedCols:=1;
- FixedRows:=1;
- for i:=1 to colcount-1 do
- begin
- cells[i, 0]:=inttostr(i);
- cells[0, i]:=inttostr(i);
- end;
- for i:=1 to colcount-1 do
- for j:=1 to rowcount-1 do
- cells[i,j]:=inttostr((i)*(j));
- end;
- end;
- procedure TForm1.StringGrid1DrawCell(Sender: TObject; aCol, aRow: Integer;
- aRect: TRect; aState: TGridDrawState);
- var
- s:string;
- begin
- if ((acol=0) or (arow=0)) and (flag<20) then
- begin
- Stringgrid1.Canvas.Brush.color := RGBTOCOLOR(Random(255), Random(255), Random(255));
- Stringgrid1.Canvas.FillRect(arect);
- Stringgrid1.Cells[acol, arow]:=Stringgrid1.Cells[acol, arow];
- StringGrid1.Canvas.TextOut(aRect.Left+2,aRect.Top+2,StringGrid1.Cells[ACol, ARow]);
- inc(flag);
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement