procedure TForm1.FormCreate(Sender: TObject);
var
i,j:integer ;
begin
Sg:=TStringGrid.Create(self);
with SG do
begin
parent:=self;
align:=alclient;
DefaultDrawing:=false;
FixedColor:=clYellow;
RowCount:=30;
ColCount:=20;
FixedCols:=1;
FixedRows:=1;
GridLineWidth:=0;
Options:=Options+[goEditing]-[goVertLine,goHorzLine,goRangeSelect];
OnDrawCell:=SGDrawCell;
OnTopLeftChanged:=SGTopLeftChanged;
Canvas.Font.name:=’宋体’;
Canvas.Font.Size:=10;
for i:=0 to colCount-1 do
for j:=0 to RowCount-1 do
cells[i,j]:=Format(’%d行%d列’,[j,i]);
for i:=0 to colCount-1 do
cells[i,0]:=Format(’第%d列’,[i]);
for i:=0 to RowCount-1 do
cells[0,i]:=Format(’第%d行’,[i]);
Cells[0,0]:=’ 左上角’;
文章来源于领测软件测试网 https://www.ltesting.net/