如何更改tcxgrid行的颜色 [英] How to change color of tcxgrid row

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

问题描述

我想用不同的颜色显示tcxgrid的某些行(取决于列的值)。

I want to show some rows from tcxgrid in different color (Depend upon column value ).

我对此进行了更改,但是在运行后它并没有反映在网格上

I did changes for it but its not getting reflected on grid after running my project.

procedure TfrmMessaging.cxGrid1DBTableView1CustomDrawCell(..);
Var
  i : Integer;
begin
  For i := 0 To cxGrid1DBTableView1.ViewData.RowCount - 1 Do
  Begin
    If cxGrid1DBTableView1.ViewData.Rows[i].Values[4] = '1' Then
    Begin
      cxGrid1.Canvas.Brush.Color := clRed;          
    End;
  End;
end;

在上面的代码中,我使用了tcxgrid的cxGrid1DBTableView1CustomDrawCell事件。
预先感谢。

In above code I have used cxGrid1DBTableView1CustomDrawCell event of tcxgrid. Thanks in advance.

推荐答案

通常,类似cxStyles的东西是最简单的方法。

Normally the easiest path for stuff like that are cxStyles. Drop a style repository on the form, add one or more styles to it and assign them in the object inspector or in an event handler (OnGetContentStyle etc.).

一个优点是,在表单上放置一个样式库,向其中添加一个或多个样式,然后在对象检查器或事件处理程序(如OnGetContentStyle等)中将其分配。自定义绘图的原因在于样式会考虑各种计算方式,而所有者绘制的单元格没有经过特别处理,有时无法正确自动调整大小等。

One advantage over custom drawing is that styles are considered for various calculations while owner drawn cells aren't handled specially and sometimes aren't autosized correctly etc.

这篇关于如何更改tcxgrid行的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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