procedure TQCCWSJ.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var
c,q: integer;
begin
if(ARow=5)and(ACol>0)then //将第2行的背景变成红色
begin
//StringGrid1.Canvas.Brush.Color := $FFECDD;
StringGrid1.Canvas.Brush.Color:=$FFECDD;
StringGrid1.Canvas.FillRect(Rect); //画红色
StringGrid1.OnDrawCell:=nil; //设置为nil,下面就不会无限递归
try
TMyGrid(StringGrid1).OnDrawCell(ACol,ARow,Rect,State);
finally
StringGrid1.OnDrawCell:=StringGrid1DrawCell; //恢复事件的地址
end;
end;
end; |