cxgrid几种条件下行变色问题与解决

cxgrid几种条件下行变色问题与解决

1 .鼠标选中行变色。

其实默认条件下,鼠标选中的行就会变色,但是被点中的单元格不变色,如果想让单元格和其它列一样的话,在cxGrid1DBTableView中找属性OptionsSelection中的CellSelect的属性变成False.但是默认颜色可能达不到使用者的要求,比如有粉粉控的人只喜欢粉色,想让选中的行变成粉色怎么办呢?很简单,只需要使cxStyleRepository控件在styles中加一种颜色就可以了。效果如图
这里写图片描述

2 .焦点不再cxgrid表中但数据库中数据对应的行变颜色。

方法有很多,我只说一种,原理是利用数据库中所指的当前行数据,然后对应到cxgrid表上。

procedure TForm1.cxGrid1DBTableView1CustomDrawCell(
  Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
      AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
if iewinfo.RecordViewInfo.Index=cxGrid1DBTableView1.Da  taController.GetFocusedRowIndex then
acanvas.Brush.Color:=clgreen;
end;

Item确定列(ID列的索引),RecordViewInfo确定行(Index行的索引)

可以定位到某一行改变颜色

if (AViewInfo.Item.ID = 0) //0列
if (AViewInfo.RecordViewInfo.Index = 0) //0行

3 .固定某行按条件变色
procedure TForm1.cxGrid1DBTableView1CustomDrawCell(
  Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
      AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
  if (AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('SheBeiBianHao').Index])='20050419' then

  begin
   ACanvas.Brush.Color := clRed;
  end;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值