TStringGrid如何给不同行不同颜色的字。我能在DBGrid中实现,但TStringGrid不支持,请教高手(50分)

D

dansl

Unregistered / Unconfirmed
GUEST, unregistred user!
TStringGrid如何给不同行填不同颜色的字。我能在DBGrid中实现,
但TStringGrid不支持DRAWSELL方法,请教高手。
 
如果简单我也想试试
 
procedure TForm1.SGDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
SG.Canvas.brush.Color :=clBlack;
if aRow mod 2=0 then
SG.Canvas.Font.Color :=clGreen
else
SG.Canvas.Font.Color:=clYellow;

if (ARow=0) or (acol=0) then
sg.Canvas.Brush.Color :=clGray;

sg.Canvas.FillRect(Rect);
sg.Canvas.TextOut(Rect.Left,Rect.Top,'Test');

end;
 
to: mr.zy 你的方法适用于填写常量。但我要用循环给CELLS填数据,你的代码怎样
操作CELLS?
 
笨蛋,将
sg.Canvas.TextOut(Rect.Left,Rect.Top,'Test');
这句改成
sg.Canvas.TextOut(Rect.Left,Rect.Top,sg.cells[arow,acol]);
不就成了吗?
 
多人接受答案了。
 
顶部