如题

解决方案 »

  1.   

    procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; 
              const Rect: TRect; DataCol: Integer; Column: TColumn; 
              State: TGridDrawState);
    begin
      if Table1.FieldByName('Population').AsInteger > 20000000 then
        TDBGrid(Sender).Canvas.Font.Color := clBlue;
      TDBGrid(Sender).DefaultDrawColumnCell(Rect, DataCol, Column, 
                                            State);
    end;
      

  2.   

    procedure TFrmVendor.DBGrid1DrawColumnCell(Sender: TObject;
      const Rect: TRect; DataCol: Integer; Column: TColumn;
      State: TGridDrawState);
    begin
      try try
          if not (gdFocused in State) then
          begin
            with DBGrid1.Canvas do
            begin
              if T_VENDPROVVStatus.AsBoolean then
                Font.Color := clBtnText
              else
                font.Color := clred
            end;
          end;
        finally
          DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
      end; except
      end;
    end;
      

  3.   

    请问一个要使dbgrid中的偶数行变色,而不是字体变色怎么做
      

  4.   

    TDBGrid(Sender).Canvas.Font.Color := clBlue;
    这就是只让行变色
      

  5.   

    sorry ! :) 错了只让行变色是
    TDBGrid(Sender).Canvas.brush.color:=blue;
      

  6.   

    这个T_VENDPROVVStatus.AsBoolean 是tadotable的什么属性?
      

  7.   

    procedure TForm5.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
      var
      i:integer;
      begin
          if (DBGrid1.DataSource.DataSet.RecNo mod 2 = 0  ) then
           begin
           dbgrid1.Canvas.Font.Color:=CLRed;       end
           else
           begin
           dbgrid1.Canvas.Font.Color:=CLBlue;       end;
           dbgrid1.DefaultDrawColumnCell(rect,datacol,column,state);
    end;
      

  8.   

    谢谢各位,我想我的表达是有问题,害得大家出了力帮忙还没帮到点子上。其实是有一个DBGrid,我先以某种条件查找到一条记录后光标就点到这条记录上,然后这条记录整个的就边成红色,是这么个意思。