|
我在stringGrid 的 drawcell事件里有如下代码,大概意思是每个四行交替变换颜色,
由于格子比较多,当stringGrid里的滚动条发生变化时,那些格子闪烁得很厉害,请问该如何解决呀.
代码如下:
var
i,j: integer;
rect: TRect;
begin
with stringGrid do
begin
for i:= 1 to RowCount do
for j:=1 to ColCount do
begin
case ch of
True: begin
Canvas.Brush.Color :=clSkyBlue;// ClBlue;
if (i mod 4 = 0) and (j=ColCount) then
if (i div 4) mod 2 =0 then
ch := False;
end;
False: begin
Canvas.Brush.Color :=clWindow;
if (i mod 4 = 0) and (j= ColCount) then
if (i div 4) mod 2 =1 then
begin
ch := True;
end ;
end;
end;
rect:= CellRect(j,i);
Canvas.FillRect(rect);
Canvas.font.color:=ClBlack;
Canvas.TextOut(rect.left , rect.top, Cells[j, i]);
end;
end;
end; |
|