delphi中stringgrid列设置背景
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏15(财富值+成长值)
1个回答
展开全部
直接在DrawCell事件中处理:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
with Sender as TStringGrid do begin
if (ACol mod 2 =0) then begin //偶数列变色
Canvas.Brush.Color := clYellow; //底色
Canvas.font.Color:=clRed; //字体颜色
end
else begin
Canvas.Brush.Color := clWindow;
Canvas.font.Color := clblue;
end;
Canvas.FillRect(Rect); /团咐亮/塌宽绘简好底色
canvas.textout(rect.Left,rect.Top,cells[Acol,ARow]); //output text
end;
参考:
http://zhidao.baidu.com/link?url=lCxdNrQiSfAR96Dl17PS4utjfUQ7ukZrAzdGV-grIuDcuD-ZawI4IwpkVh2zBCPz99f6CrfnywvRUUxRQxwD6a
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
with Sender as TStringGrid do begin
if (ACol mod 2 =0) then begin //偶数列变色
Canvas.Brush.Color := clYellow; //底色
Canvas.font.Color:=clRed; //字体颜色
end
else begin
Canvas.Brush.Color := clWindow;
Canvas.font.Color := clblue;
end;
Canvas.FillRect(Rect); /团咐亮/塌宽绘简好底色
canvas.textout(rect.Left,rect.Top,cells[Acol,ARow]); //output text
end;
参考:
http://zhidao.baidu.com/link?url=lCxdNrQiSfAR96Dl17PS4utjfUQ7ukZrAzdGV-grIuDcuD-ZawI4IwpkVh2zBCPz99f6CrfnywvRUUxRQxwD6a
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询