(请同时参考如何动态更新DBGrid的颜色?/如何使DBGRID网格的颜色随此格中的数据值的变化而变化?)
在应用系统中,用户常常要求把数据按不同的颜色显示出来,只要你在 Dbgrid 的 DrawColumnCell 事件中加入以下代码就可以了: If Query.fieldbyname('字段名').values 满足条件 then Begin Dbgrid.Canvas.Brush.Color := 颜色(如:clInfoBk) ; Dbgrid.DefaultDrawColumnCell( Rect, DataCol, Column, [gdFixed,gdFocused,gdSelected] ); End ;
(编辑:aniston)
|