procedure TFrmMain.StringGrid2DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
case StringGrid2.Tag of
0:
begin
StringGrid2.Canvas.Font.Color := clBlack;
StringGrid2.Canvas.textrect(Rect,Rect.left,Rect.Top,StringGrid2.Cells[ACol,ARow]);
end;
1:
begin
StringGrid2.Canvas.Font.Color := clRed;
StringGrid2.Canvas.textrect(Rect,Rect.left+2,Rect.Top+2,StringGrid2.Cells[ACol,ARow]);
end;
else;
end;
end;我这么写的代码,能实现用不同颜色标记记录。
但好象StringGrid在每次显示的时候也会触发StringGrid2DrawCell事件,把StringGrid中所有记录重画了,变成一个颜色显示了。也就是我用不同颜色显示的数据,不能永久保留怎么办?
这个情况该怎么解决呀。
ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
case StringGrid2.Tag of
0:
begin
StringGrid2.Canvas.Font.Color := clBlack;
StringGrid2.Canvas.textrect(Rect,Rect.left,Rect.Top,StringGrid2.Cells[ACol,ARow]);
end;
1:
begin
StringGrid2.Canvas.Font.Color := clRed;
StringGrid2.Canvas.textrect(Rect,Rect.left+2,Rect.Top+2,StringGrid2.Cells[ACol,ARow]);
end;
else;
end;
end;我这么写的代码,能实现用不同颜色标记记录。
但好象StringGrid在每次显示的时候也会触发StringGrid2DrawCell事件,把StringGrid中所有记录重画了,变成一个颜色显示了。也就是我用不同颜色显示的数据,不能永久保留怎么办?
这个情况该怎么解决呀。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货