向大家请教:
     现在我一个表,在DbGridEh里显示,我想对此表进行检验,然后把此表中不符合条件的单元格进行变色,以显区分.
   例如:有的表里有数据
            姓名        数学分 英语分  物理分  化学分
   第一条:  张三        80    45     57     70
           李四         43    75     61     50
           王五         99    87     90    55
    把所有不及格的信息进行颜色区分。请大侠门帮忙!
      

解决方案 »

  1.   

    TO GDTOPONE : 
       是所有不及格的进行颜色区分
      

  2.   

    很简单的 在 OnGetCellParams 事件中写到
    begin
      if 条件 then
      begin
        AFont.Color := clRed;
        AFont.Style := [fsStrikeOut];
      end;
    end;
      

  3.   


    procedure TForm1.DBGridEh1DrawColumnCell(Sender: TObject;
      const Rect: TRect; DataCol: Integer; Column: TColumnEh;
      State: TGridDrawState);
    begin
    {数学分 英语分  物理分  化学分}
     if (ADOQuery1.FieldByName('数学分').AsInteger <60) and
        (ADOQuery1.FieldByName('英语分').AsInteger <60)  and
        (ADOQuery1.FieldByName('物理分').AsInteger <60)  and
        (ADOQuery1.FieldByName('化学分').AsInteger <60) then
     begin
       if (State = [gdSelected]) or (State = [gdSelected, gdFocused]) then
          DBGridEh1.Canvas.Font.Color := clYellow
         else
         DBGridEh1.Canvas.Font.Color := clGreen;
       DBGridEh1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
     end;
    end;
    end;
      

  4.   


    procedure TForm1.DBGridEh1GetCellParams(Sender: TObject; Column: TColumnEh;
      AFont: TFont; var Background: TColor; State: TGridDrawState);
    begin
    if (ADOQuery1.FieldByName('数学分').AsInteger <60) and
        (ADOQuery1.FieldByName('英语分').AsInteger <60)  and
        (ADOQuery1.FieldByName('物理分').AsInteger <60)  and
        (ADOQuery1.FieldByName('化学分').AsInteger <60) then
                  Background   :=   $00FFC4C4
              else
                  Background   :=   $00FFDDDD;end;
    以上两种方法,你看喜欢那种
      

  5.   

    以上楼主的方法都可以
    我一直是在DBGridEh1DrawColumnCell事件写代码控件的.
      

  6.   


    procedure TForm1.DBGridEh1GetCellParams(Sender: TObject; Column: TColumnEh;
      AFont: TFont; var Background: TColor; State: TGridDrawState);
    begin
    if ((ADOQuery1.FieldByName('数学分').AsInteger <60) and
        (ADOQuery1.FieldByName('英语分').AsInteger <60)  and
        (ADOQuery1.FieldByName('物理分').AsInteger <60)  and
        (ADOQuery1.FieldByName('化学分').AsInteger <60)) or 
        (ADOQuery1.FieldByName('化学分').AsInteger <ADOQuery1.FieldByName('物理分').AsInteger) then
                  Background   :=   $00FFC4C4
              else
                  Background   :=   $00FFDDDD;end;
      

  7.   

    楼主找的是这个么???
    DbNetList是一个综合功能的列表选择组件,作为动态HTML(DHTML)实现。运用DbNetList,你可以快速为自己的web页面添加数据库驱动的列表、下拉式列表(drop-down)、树型和复选框列表。DbNetList兼容最流行的各种数据库服务器,包括:SQL Server、Oracle和Informix。具体功能:    生成列表、多列列表、下拉式列表(drop-down)、树型列表、复选框列表...
        提供ASP 和 ASP.NET的本地版本。
        基于浏览器。无论何处均可设计和运行。无需客户端安装。无需Java。纯DHTML。
        完全封装的组件。轻松与任一web页面整合。
        生成稳健的基于web的应用程序。
        支持大量数据库,包括:SQL Server、 MSDE、 Oracle、 Sybase、 DB2、 MySQL、 Access、 Visual Fox Pro、 InterSystems Caché、 Informix 等,还有更多。
        完全可以自定义配置。
        DbNetList特别为拓展微软IE家族浏览器的性能而设计,你的客户端将需要IE 5.0或更高版本。实际上,只需几行代码,就把一个DbNetList包含到了你的应用程序。甚至通常复杂的结构,比如嵌套的树状列表,也仅仅需要几行代码就可以实现:
        DbNetList包含了所有这些强大的、额外的功能
        列表中附加的隐藏数据项目,可以被获取、作为每一个行/节点的属性存储并可以通过程序操作。
        通过selectData()方法发出ad-hoc数据库询问。
        "按需"扩展的树型列表 - 管理大型嵌套目录,无需在顶层预先载入整个结构。
        自动完成 - 当定焦在DbNetList时,键入一串字符,第一个匹配行将自动高亮。