如何根据表值对cxgrid进行着色? [英] How do I color a cxgrid based on table value?

查看:212
本文介绍了如何根据表值对cxgrid进行着色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在特定字段名称hello中存在的所有行都可以获得彩色
绿色。我试过这个在 customdrawcell

I would like all rows where in particular field name 'hello' is present to get colored green. I tried this on customdrawcell:

if abstable1.fieldbyname('somename').asstring = 'Hello' then
  cxgrid.canvas.brush.color:=clGreen

但是它不会工作...我在这里缺少什么?

But it wont work... what am I missing here ?

推荐答案

不要尝试改变画布颜色格。相反,我发现这个总是是真的 - 更改 View 的OnDrawCell处理程序中的颜色,如下例所示:

Don't try to change canvas colors in the Grid. Rather--and I find this to always be true--change colors in the View's OnDrawCell handler, as in this example:

procedure T_fmTabSnapList.View1CustomDrawCell(Sender: TcxCustomGridTableView;
  ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
  if abstable1.fieldbyname('somename').asstring = 'Hello' then 
    ACanvas.Brush.Color := clGreen
end;

cxGrid只是视图的一个容器。意见是所有绘画的地方。
s

The cxGrid is just a container for Views. Views are where all the painting occurs. s

这篇关于如何根据表值对cxgrid进行着色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆