if ((State=[gdSelected])or(State=[gdSelected,gdFocused])) then
begin
DbGrid1.Canvas.Brush.color:=clred;
//file://当前行以红色显示,其它行使用背景的浅绿色   
//DbGrid1.Canvas.pen.mode:=pmmask;  
DbGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
然后将DBGRID的option dgrowselect 设成true这样可以实现选定行全是红色,但是有得字段的PICKLIST的值无法进行下拉的选择??
不知道有解决的办法吗??

解决方案 »

  1.   

    dgrowselect  已经是行选了. 
      

  2.   

    是呀,设定此属性后,DBGRID的OPTION的DGEDITING的属性就变成了FALSE,不知道能实现的其它的方式吗??
      

  3.   

    可以,放一个edit上去,让在grid的自画事件中绑定edit到选中单元格,然后在edit中写值并提交
      

  4.   


    procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
      Field: TField; State: TGridDrawState);
    begin
      if (DBGrid1.SelectedField = Field) and (gdfocused in State) then
      begin
        Edit1.Visible := True;
        Edit1.SetBounds(DBGrid1.Left+rect.Left,DBGrid1.Top+ Rect.Top,Rect.Right-rect.Left,Rect.Bottom-rect.Top);
        Edit1.Text := Field.AsString;
      end;
    end;
      

  5.   

    考虑在按下修改时将dgrowselect设为FALSE,DGEDITING设为TRUE提交或取消后再把这两个属性改回去.