救命啊?
如何在DBGrid中用鼠标拖动记录,例如把第三行拖到地四行

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, Grids, DBGrids, DB, ADODB;type
      TForm1 = class(TForm)
        DataSource1: TDataSource;
        ADOConnection1: TADOConnection;
        ADOTable1: TADOTable;
        DBGrid1: TDBGrid;
        procedure FormCreate(Sender: TObject);
      private
        Procedure OnMouseWheel(Var Msg :TMsg;var Handled:Boolean);
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}{ TForm1 }procedure TForm1.OnMouseWheel(var Msg: TMsg; var Handled: Boolean);
    begin
      if Msg.message = WM_MouseWheel then
      begin
        if Msg.wParam > 0 then
         begin
           if DBGrid1.Focused then
             SendMessage(DBGrid1.Handle,WM_VSCROLL,SB_PAGEUP,0);
         end
        else
         begin
           if DBGrid1.Focused then
             SendMessage(DBGrid1.Handle,WM_VSCROLL,SB_PAGEDOWN,0);
         end;
        Handled:= True;
      end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      Application.OnMessage:=OnMouseWheel;
    end;end.
      

  2.   

    to anlongu(dabing)
    楼上的误会楼主的意思了。不过上面的代码对我有用:)