DBGridEH的某一列的值有Y和N,
现在要把值为Y的那一行设置颜色,怎样实现
现在要把值为Y的那一行设置颜色,怎样实现
解决方案 »
- 如何高效率检测图形中指定像素的像素值?
- 怎样在windows mediaplayer里播放二进制文件?
- ***小弟想开发个rs485 的IC卡程序****
- 高手们关注一下:一个分布式系统开发,不太熟悉,给些见意,小弟谢了
- ★★★哈哈哈,终于被提前释放了!!散分200★★★
- 过年回去的卧铺票已经搞定了,高兴,散分!
- 用Delphi写ASP组件导数据库中的内容到Excel
- WaitForSingleObject的问题?
- 老问题,请高手给个答案。在线等待 急急急急急急急!!!
- -----如何将一个MS-SQL数据库按条件导入到一个ACCESS数据库!包括在ACCESS里面建表-----
- 求助:delphi image组件问题
- 如何获取TDBGrid里某个单元格的句柄?
const Rect: TRect; DataCol: Integer; Column: TColumnEh;
State: TGridDrawState);
begin
if adoquery1.fieldbyname('合计数量').AsInteger> adoquery1.fieldbyname('KC').AsInteger then
begin
(Sender as TDBGridEH).Canvas.Brush.Color := $008080FF;
end;
DBGridEh1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
例如在DBGridEh的OnDrawColumnCell事件里输入如下代码:
if ADOQuery1.FieldByName('status').AsString='True' then //如果条件成立
begin
DBGridEh1.Canvas.Brush.Color:=clSilver; //行底色变色
DBGridEh1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
另一种:
if ADOQuery1.FieldByName('status').AsString='True' then //如果条件成立
begin
DBGridEh1.Canvas.Font.Color:=clMaroon; //行字体变颜色
DBGridEh1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
DBGridEh1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
procedure TForm1.DBGridEh1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumnEh;
State: TGridDrawState);
begin
if (column.FieldName = 'DEL') and (column.Field.Value = 'Y') then
begin
DBGridEh1.Canvas.Brush.Color := clYellow;
end;
DBGridEh1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
我写了这行代码,但是DEL列中值为Y的一行,颜色没有变化