可以在stringgrid的onDrawCell事件里写一些语句来实现,下面是一个例子。
procedure TForm_Main.StringGrid1DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
str: string;
sg:TStringGrid;
begin
sg:=sender as TStringGrid;
if gdFixed in state then
sg.Canvas.Brush.Color := sg.FixedColor //设置固定行或列颜色
else
sg.Canvas.Brush.Color := sg.Color;//设置其他cell背景色
if arow=0 then sg.Canvas.Font.Color := clRed
//设置第一行颜色,其他行可以用同样方法设置
else
sg.Canvas.Font.Color := sg.Font.Color;
sg.Canvas.textrect(Rect,Rect.left+A1,Rect.Top+A2,sg.Cells[Col,Row]);end;
在提问题前先查一下以前的问题,这个答案其实是从以前回答的问题里找到的。
procedure TForm_Main.StringGrid1DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
str: string;
sg:TStringGrid;
begin
sg:=sender as TStringGrid;
if gdFixed in state then
sg.Canvas.Brush.Color := sg.FixedColor //设置固定行或列颜色
else
sg.Canvas.Brush.Color := sg.Color;//设置其他cell背景色
if arow=0 then sg.Canvas.Font.Color := clRed
//设置第一行颜色,其他行可以用同样方法设置
else
sg.Canvas.Font.Color := sg.Font.Color;
sg.Canvas.textrect(Rect,Rect.left+A1,Rect.Top+A2,sg.Cells[Col,Row]);end;
在提问题前先查一下以前的问题,这个答案其实是从以前回答的问题里找到的。
现在我用的advsringgrid功能强的无法形容
现在我用的advsringgrid功能强的无法形容,且全中文打印预揽截面。
[email protected],发信并给分!