delphi2007 教程

delphi2007 教程

首页 新随笔 联系 聚合 管理
  1013 Posts :: 0 Stories :: 28 Comments :: 0 Trackbacks
请问,怎么在DBGRID中改变CELL内容 Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiDB/html/delphi_20061216104516278.html
我写了以下代码:但是还是显示数字  
  procedure   TMakeTicket.DBGridEh3DrawColumnCell(Sender:   TObject;  
      const   Rect:   TRect;   DataCol:   Integer;   Column:   TColumnEh;  
      State:   TGridDrawState);  
  begin  
      inherited;  
      with   DBGridEh3.Canvas   do  
      case   ADOQuery2.FieldByName('status').AsInteger   of  
      1:TextRect(Rect,Rect.Left,((Rect.Bottom-Rect.Top)-TextHeight('处理'))   div   2,'处理');  
      2:TextRect(Rect,Rect.Left,((Rect.Bottom-Rect.Top)-TextHeight('未处理'))   div   2,'未处理');  
        end;  
    DBGridEh3.DefaultDrawColumnCell(Rect,   DataCol,   Column,   State);  
  }

去掉inherited试试

procedure   TMakeTicket.DBGridEh3DrawColumnCell(Sender:   TObject;  
      const   Rect:   TRect;   DataCol:   Integer;   Column:   TColumnEh;  
      State:   TGridDrawState);  
  begin  
      inherited;  
      if   Column.FieldName   =   'Status'   then  
      begin  
          with   DBGridEh3.Canvas   do  
          begin  
              FillRect(Rect);  
              case   ADOQuery2.FieldByName('status').AsInteger   of  
              1:TextRect(Rect,Rect.Left,((Rect.Bottom-Rect.Top)-TextHeight('处理'))   div     2,'处理');  
              2:TextRect(Rect,Rect.Left,((Rect.Bottom-Rect.Top)-TextHeight('未处理'))   div   2,'未处理');  
          end;  
      end   else  
      DBGridEh3.DefaultDrawColumnCell(Rect,   DataCol,   Column,   State);

1:TextRect(Rect,Rect.Left,((Rect.Bottom-Rect.Top)-TextHeight('处理'))   div     2,'处理');  
              2:TextRect(Rect,Rect.Left,((Rect.Bottom-Rect.Top)-TextHeight('未处理'))   div   2,'未处理');  
   
  ============可以简洁点  
   
    1:TextOout(Rect.Left,   Rect.Top+2,'处理');  
    2:TextOout(Rect.Left,   Rect.Top+2,'未处理');

1:TextOout(Rect.Left+2,   Rect.Top+2,'处理');  
    2:TextOout(Rect.Left+2,   Rect.Top+2,'未处理');

posted on 2009-05-12 16:02 delphi2007 阅读(238) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。