刚输入一条记录,要怎样才能改变当前输入记录的颜色.急.........

解决方案 »

  1.   

    在DBGrid中,怎样才能让我能点击一个单元格选择整行,又可以编辑单元格的内容呢?
    在设计过程中,有时候数据较大量,field 较多的时候,只是点击单元格可能会对某个field的数据误操作(如数据错行),为此才会想到这个问题,解决办法如下:
        点击单元格就改当前行颜色。这个办法也算是没办法的办法吧!type
     TMyDBGrid=class(TDBGrid);
    //////////////////////////////////
    //DBGrid1.Options->dgEditing=True
    //DBGrid1.Options->dgRowSelect=False
    procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
     DataCol: Integer; Column: TColumn; State: TGridDrawState);
    begin
     with TMyDBGrid(Sender) do
     begin
       if DataLink.ActiveRecord=Row-1 then
       begin
         Canvas.Font.Color:=clWhite;
         Canvas.Brush.Color:=$00800040;
       end
       else
       begin
         Canvas.Brush.Color:=Color;
         Canvas.Font.Color:=Font.Color;
       end;
       DefaultDrawColumnCell(Rect,DataCol,Column,State);
     end;
    end; 测试通过(d7)! http://dev.csdn.net/article/53/53439.shtm  DBGrid应用全书(一) 
    http://dev.csdn.net/article/53/53440.shtm  DBGrid使用全书(二)
    http://dev.csdn.net/article/53/53441.shtm  DBGrid使用全书(三) 
    http://dev.csdn.net/article/53/53442.shtm  DBGrid使用全书(四)
    http://dev.csdn.net/article/53/53443.shtm  DBGrid使用全书(五)