一般dbgrid的dgEditing和dgRowselect属性是互斥的,dbGrid能编辑的话,怎么才能使要编辑的单元格所在的一整行行显示颜色?

解决方案 »

  1.   

    我知道答案了,通过一个星期的搜索终于找到答案了!
    现将代码展示如下:
    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; 本段代码是我在:“乘风原创程序(http://www.qqcf.com)”处搜到的详细出处参考:http://study.qqcf.com/web/523/100400.htm