TstringGrid

yexiaomin 2004-01-01 09:37:40
怎样使StringGrid一行选中,并改变背景色
...全文
88 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xyc189 2004-01-02
  • 打赏
  • 举报
回复
要设置Options属性中的goRowSelect为True,然后StringGrid.Row := 10,改背景色写OnDrawCell事件
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var s:String;
begin
if (ARow = StringGrid1.Row) and (ACol>=StringGrid1.FixedCols) then
begin
StringGrid1.Canvas.Brush.Color := clRed;
StringGrid1.Canvas.FillRect(Rect);
end;
end;
chw_csdn_chw 2004-01-01
  • 打赏
  • 举报
回复
StringGrid.row:=10;

背景色最好不要改了,因为选中后会变蓝色,即使你改为红色也显示不出来。


5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧