How do I drag and drop from a TDBGrid?

≯℡__Kan透↙ 提交于 2019-12-11 06:35:38

问题


If I set DragMode to dmAutomatic it prevents me from selecting rows. If I used OnCellClick to call BeginDrag it only fires on mouse up, which is not dragging in my opinion. If I use OnMouseDown it only fires on title row.

How I am I supposed do it?


回答1:


Overloading MouseDown will lead to the desired result.

type
  TDBGrid=Class(DBGrids.TDBGrid)
         procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
  End;


  TForm2 = class(TForm)
    .......
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

{ TDBGrid }

procedure TDBGrid.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  Begindrag(false);
  inherited;
end;


来源:https://stackoverflow.com/questions/16796669/how-do-i-drag-and-drop-from-a-tdbgrid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!