在查询数据时,当查到的某个字段为空时怎么让这个字段在DBGrid显示为0!
谢谢!

解决方案 »

  1.   

    在DbGrid的DBGrid1DrawColumnCell或者OnDBGrid1DrawDataCell事件中写入判断条件,然后就可以控制输出了
      

  2.   

    如果用的是ado查询sql 可以直接写.
    select isnull(field,0) as field from table
    或者
    双击你的adoquery,or adotable ,table
    添加所有的字段进来,选中你要设置的字段, 再
    找到他的gettext事件
    procedure TdmBasicMDForm.RecordStateGetText(Sender: TField;
      var Text: String; DisplayText: Boolean);
    begin
    if sender.isnull Then
       text:=0
    end;