////加入如下代码,实现StringGrid的第二行为黄色
procedure TForm1.StringGrid1DrawCell(Sender: TObject;
ACol, ARow: Integer;
Rect: TRect;
State: TGridDrawState);
var
dx, dy, i: byte;
begin
if (arow = 2) and not (acol = 0) then
with stringgrid1 do
begin
canvas.Brush.color := clYellow;
canvas.FillRect(Rect);
canvas.font.color := clblue;
dx := 2;
//调整此值,控制字在网格中显示的水平位置
dy := 2;
//调整此值,控制字在网格中显示的垂直位置
canvas.TextOut(rect.left + dx, rect.top + dy, cells[acol, arow]);
end;
end;