📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
NewColor:TColor;
begin
Randomize();
NewColor:=RGB(Random(255),Random(255),Random(255));
self.StringGrid1.Canvas.Brush.Color:=NewColor;
self.StringGrid1.Canvas.FillRect(Rect);
self.StringGrid1.Canvas.TextOut(Rect.Left+2,Rect.Top+2,self.StringGrid1.Cells[ACol,ARow]);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i,j:Integer;
begin
for i:=0 to self.StringGrid1.ColCount-1 do
begin
for j:=0 to self.StringGrid1.RowCount-1 do
begin
self.StringGrid1.Cells[i,j]:= IntToStr(i*j);
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -