当指定的单元格需要指定样式(如字体颜色设置为红色,背景色设置为黄色)时,可按如下步骤进行:

 

1、添加 csStyleRepository 控件,并新建 Style,设置前景(TextColor)、背景色(Color)。

2、编写 cxGrid 中 Table 组件的 Styles.OnGetContentStyle 事件:

procedure TAccumulationFundForm.gridAccumulationFundStylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; var AStyle: TcxStyle);
begin
  if AItem.Index = gridAccumulationFundPERSON_NAME.Index then
  begin
    if ARecord.Values[gridAccumulationFundHAS_EMPLOYEE.Index] = 'N' then
    begin
      AStyle := dmResource.Style_IdCardNotExists;
    end;
  end;
end;

注意:

上面代码的意思是指:如果 AItem 就是要设置 Style 的单元格的话,则找到 ARecord 数据中的指定字段值进行条件匹配,如果成功,则设置 AStyle 为指定的样式对象。这样,则达到效果。

相关文章:

  • 2021-05-14
  • 2022-03-02
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2021-05-07
猜你喜欢
  • 2022-02-06
  • 2022-12-23
  • 2022-01-11
  • 2022-01-28
  • 2022-12-23
  • 2021-12-24
  • 2022-12-23
相关资源
相似解决方案