当前位置:Gxlcms > 数据库问题 > 在DBGrid中,单击单元格选择整行,双击又可编辑单元格

在DBGrid中,单击单元格选择整行,双击又可编辑单元格

时间:2021-07-01 10:21:17 帮助过:22人阅读



一、先在implementation前做如下定义
type
  TMyDBGrid=class(TDBGrid);


二、在DBGrid的OnDrawColumnCell操作
procedure Tfrm_hetong.DBGrid2DrawColumnCell(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;

在DBGrid中,单击单元格选择整行,双击又可编辑单元格

标签:默认   link   单击   font   双击   select   proc   const   canvas   

人气教程排行