我自己写了个改变stringgrid当前行颜色的代码,可是实际运行的时候只能改变当前格子的.
查了下论坛其他类似问题也没解决,就厚颜把自己代码放上来请大家指出错误了.
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if gdSelected in State then
with TStringGrid(Sender) do
begin
StringGrid1.Canvas.Brush.Color:=colorGrid1.ForegroundColor;
StringGrid1.Canvas.Font.Color := colorGrid1.BackgroundColor;
StringGrid1.Canvas.FillRect(rect);
DrawText(StringGrid1.Canvas.Handle,Pchar(StringGrid1.Cells[aCol,aRow]),Length(StringGrid1.Cells[aCol,aRow]),rect,0);
end;
end;
查了下论坛其他类似问题也没解决,就厚颜把自己代码放上来请大家指出错误了.
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if gdSelected in State then
with TStringGrid(Sender) do
begin
StringGrid1.Canvas.Brush.Color:=colorGrid1.ForegroundColor;
StringGrid1.Canvas.Font.Color := colorGrid1.BackgroundColor;
StringGrid1.Canvas.FillRect(rect);
DrawText(StringGrid1.Canvas.Handle,Pchar(StringGrid1.Cells[aCol,aRow]),Length(StringGrid1.Cells[aCol,aRow]),rect,0);
end;
end;
帮助文档是强大的
我太急了