如题,着急等待,谢谢帮忙!

解决方案 »

  1.   

    双击dbgrid,在谈出属性框中点'add all fields',
    选中指定字段,在object inspector中color属性设置
      

  2.   

    怎么能够对DBgrid里面显示的数据进行上色
      

  3.   

    procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;Field: TField; State: TGridDrawState);
      begin
         if Table1.Fieldbyname(′Salary′).value<=SpinEdit1.value then
            DBGrid1.Canvas.Brush.Color:=ColorGrid1.ForeGroundColor
       else
            DBGrid1.Canvas.Brush.Color:=ColorGrid1.BackGroundColor;
         DBGrid1.Canvas.FillRect(Rect);
         DBGrid1.Canvas.TextOut(Rect.left+2,Rect.top+2,Field.AsString);
      end;
      

  4.   

    这是我写的一个例子,你看看
    procedure TForm15.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    var
      i,j:integer;
    begin
      i:=form15.DBGrid1.DataSource.DataSet.RecordCount;
      if i>0 then
      begin
        for j:=0 to i-1 do
        begin
          if form15.DBGrid1.DataSource.DataSet.FieldValues['zt']='未读' then
          begin
            datacol:=form15.DBGrid1.DataSource.DataSet.RecNo;
            if not form15.DBGrid1.SelectedRows.CurrentRowSelected then
              form15.DBGrid1.Canvas.Brush.Color:=clred;
            form15.DBGrid1.Canvas.Brush.Color:=clred;
            form15.DBGrid1.Canvas.Pen.Mode:=pmmask;
            form15.DBGrid1.DefaultDrawColumnCell(rect,datacol,column,state);
          end;
        end;
      end;
    end;
      

  5.   

    忘了
    dbgrid属性中的option中的rowselect设置为true
      

  6.   

    在dbgrid的onDrawColumnCell中加入如下程序:
    if “满足变色条件” then    
       dbgrid1.canvas.font.color:=clred;
    else dbgrid1.canvas.font.color:=clblue;dbgrid1.DefaultDrawColumnCell(rect,datacol,column.state);
      

  7.   

    还是没有了解到我的意思。
    不用判断,直接是对某一列 是一列的数据进行上色。zyrlxy(海妖)给解答的是整个DBGrid的数据数据都上色了,
      

  8.   

    procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    begin
      if column.Field.Value='條件表達式' then
      with DBGrid1.Canvas do
      begin
        brush.Color:=clred;
        font.Color:=clblue;
        dbgrid1.DefaultDrawColumnCell(rect,datacol,column,state);
      end;
    end;
      

  9.   

    不知道条件表达式是怎么样写,我这样写 '基本价' 或者'jbjia' 出现以下错误
    "Invalid variant type conversion"
      

  10.   

    在dbgrid的OnDrawColumnCell事件中加入代碼:
    if 等于特定行 then
      begin
      DBgrid1.Canvas.Brush.Color := clLime;
      DBgrid1.Canvas.font.Color := clBlue;
      end
    else
      begin
      DBgrid1.Canvas.Brush.Color :=claqua;
      DBgrid1.Canvas.font.Color :=clred;
      end;
      

  11.   

    不明白楼主的意思
    既然要把重要的那列选出来肯定是要通过判断的
    dbgrid1.columns[0].color:=clred  //第一列的颜色
      

  12.   

    行的颜色,在这里有个例子,可以下来看看
    http://www.kaer.com.cn/default.aspx
      

  13.   

    JassonYe(没日没夜) :
      不用了解了,你给的就是我想得到的答案。谢谢!