zoukankan      html  css  js  c++  java
  • 在DBGrid中,单击单元格选择整行,双击又可编辑单元格

    在设计过程中,有时候数据较大量,field 较多的时候,只是点击单元格可能会对某个field的数据误操作(如数据错行),为此才会想到这个问题,解决办法如下:点击单元格就改当前行颜色。

    首先DBGRID的属性做好下设置(其实也是DBGRID默认的属性)

    DBGrid1->Options->dgEditing=True
    DBGrid1->Options->dgRowSelect=False


    一、先在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;

  • 相关阅读:
    python基础7
    python基础7
    十大经典预测算法(一)----线性回归
    RNN-循环神经网络
    CNN之经典卷积网络框架原理
    卷积神经网络CNN
    决策树的生成
    欠拟合、过拟合及解决方法
    决策树
    KD树
  • 原文地址:https://www.cnblogs.com/jijm123/p/7538399.html
Copyright © 2011-2022 走看看