这好像没办法,那是windows的默认颜色

解决方案 »

  1.   

    写DBGrid的OnDrawDataCell事件就行了
    procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; 
           const Rect: TRect;Field: TField; State: TGridDrawState);
    begin
      if gdSelected in State then
      begin
        DBGrid1.Canvas.Brush.Color:=clWhite;
        DBGrid1.DefaultDrawDataCell(Rect,Field,State);
      end;
    end;
      

  2.   

    写DBGrid的OnDrawDataCell事件就行了
    procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; 
           const Rect: TRect;Field: TField; State: TGridDrawState);
    begin
      if gdSelected in State then
      begin
        DBGrid1.Canvas.Brush.Color:=clWhite;
        DBGrid1.Canvas.Font.Color:=clBlack;
        DBGrid1.DefaultDrawDataCell(Rect,Field,State);
      end;
    end;
      

  3.   

    可能在OnDrawCell里面可以改
    If Query.fieldbyname('字段名').values 满足条件 then 
     Begin
        Dbgrid.Canvas.Brush.Color := 颜色(如:clInfoBk) ;      Dbgrid.DefaultDrawColumnCell( Rect, DataCol, Column, [gdFixed,gdFocused,gdSelected] );
      End ;
      

  4.   


    procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    begin
      if gdselected in state then
        begin
            dbgrid1.Canvas.brush.Style:=bsClear;//很重要
            dbGrid1.Canvas.Brush.color:=clgreen;//随便改个颜色
            dbgrid1.DefaultDrawColumnCell(rect,datacol,column,state);
        end;
    end;
      

  5.   

    由于要在DBGRID中的各行中选择行删除等操作,我把DBGRID的DGMULTISELECT设置为真,选择行时出现点击的列是白色,但同行的其他列是兰色。也用了ONCOLOMNDRAWCELL和ONDATADRAWCELL事件。
      

  6.   

    很简单
    defaultdrawing:=flase;
      

  7.   

    defaultdrawing:=flase;
    这个我也设置了的,但是要在DBGRID的单元格中点击时才显示出字段具体的数据。
      

  8.   

    defaultdrawing:=flase;procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    begin
      if gdselected in state then
        begin
            dbgrid1.Canvas.brush.Style:=bsClear;//很重要
            dbGrid1.Canvas.Brush.color:=clgreen;//随便改个颜色
        end;
      //将此句放在if判断的外面 
      dbgrid1.DefaultDrawColumnCell(rect,datacol,column,state);
    end;
      

  9.   

    以上的答复还有问题,我要在dbgrid中编辑数据,而且要实现点击的当前记录变色,当前列的颜色为另一种颜色,就像pb中一样,能实现吗,各位高手
      

  10.   

    在DBGird中如何改变记录的颜色  第一步,把DefaultDrawing属性设置为False.    让我们考虑下面的例子:  我们有一个使用CachedUpdates的dataset。而用户需要知道哪些记录是已经编辑过的,哪些是新的和哪些是已经删除的。  上述讲到的CachedUpdates可以用UpdateStatus函数进行设置。为了要从dateset中显示被删除的记录(在确认更新之前),我们要修改UpdateRecordTypes属性。该属性详细地描述了哪些记录将要在dataset中显示出来--默认为[rtModified, rtInserted, rtUnmodified]。  因此,在我们的代码中要加入下面的一行:UpdateRecordTypes := UpdateRecordTypes + [rtDeleted];  现在让我们为DBGrid的OnDrawColumnCell事件添加下面的代码;procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    begin
      with (Sender as TDBGrid).Canvas do begin
        case (DataSource.DataSet as TBDEDataSet).UpdateStatus of
          usInserted : Brush.Color := clRed;
          usModified : Brush.Color := clBlue;
          usDeleted  : begin Brush.Color := clBlack; Font.Color := clWhite; end;
        end;
        DefaultDrawDataCell(Rect, Column.Field, State);
      end;
    end;  DefaultDrawDataCell现在将会用新的font和brush属性来显示文本,很简单吧 :)      
      

  11.   

    这个问题没有解决好,
    它的问题是:
    在dbgrid中的多个行,在其中的任一行中的一列点击时,这一列是白色,但其他列是兰色。
      

  12.   

    在DBGrid的[OPTIONS]中找一个好像跟Select有关的选项。具体名称我给忘了,肯定能完成你的要求。