• Delphi DBGrid记录全选和反选拖动处理


    DBGrid1.DragMode   :=   dmManual;//留意这个设置不要变

    procedure ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);

    procedure TForm18.ApplicationEvents1Message(var Msg: tagMSG;
    var Handled: Boolean);
    begin
    case   Msg.message   of
              WM_LBUTTONDOWN:
              begin
                  if   Msg.hwnd   =   DBGrid1.Handle   then
                  begin
                      DBGrid1.Perform(Msg.message,   Msg.wParam,   Msg.lParam);
                      DBGrid1.DragMode   :=   dmAutomatic;
                  end;
              end;
              WM_LBUTTONUP:   DBGrid1.DragMode   :=   dmManual;
          end;
    end;

    ---------------------------------------------------------------

    procedure TForm10.SpeedButton7Click(Sender: TObject);

    //全选

    begin
       with DBGrid1.datasource.dataset do
       begin
          First;
          while not dm.AQ_personal.EOF   do
          begin
             DBGrid1.SelectedRows.CurrentRowSelected := True;
             dm.AQ_personal.Next;
          end;
       end;
    end;

    procedure TForm10.SpeedButton8Click(Sender: TObject);//反选
    var
    i:integer;
    SavePlace:TBookmarkList;
    begin
    DBGrid1.DataSource.DataSet.DisableControls;
    for   i:=1   to   DBGrid1.DataSource.DataSet.RecordCount   do
    begin
        DBGrid1.DataSource.DataSet.RecNo:=i;
        DBGrid1.SelectedRows.CurrentRowSelected:=Not DBGrid1.SelectedRows.CurrentRowSelected;
    end;
    SavePlace:=DBGrid1.SelectedRows;
    //    DBGrid1.DataSource.DataSet.GotoBookmark(Pointer(SavePlace[0]));//将指针指向当前选择的第一条记录
    DBgrid1.DataSource.DataSet.EnableControls;
    end;

  • 相关阅读:
    jstree单选功能的实现方法
    JavaScript之HTML DOM Document 对象
    任意用户密码重置漏洞
    MESSAGE_TYPE_X dump in RSM_DATASTATE_CHECK -6-
    高版本Visual Studio和低版本ArcGIS共存 工具箱没有控件的解决方法
    定制Dynamics 365 Portal 界面
    从组件文档引发的惨案 ◤1◢
    图文结合深入理解 JS 中的 this 值
    js获取时间差值
    vscode 同步扩展插件
  • 原文地址:https://www.cnblogs.com/jijm123/p/8087997.html
Copyright © 2020-2023  润新知