[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

Drag & Drop between ListViews

How can I make a "Drag & Drop" between two ListViews?
I have a component that handles all other drag and drops such as: from the desktop, from explorer or any other file manager. However it doesn't work with another ListView.
0
jonassondaniel
Asked:
jonassondaniel
  • 2
1 Solution
 
ZifNabCommented:
Hi jonassondaniel,

Have you got D2, or D3? Because in D2 there is a bug, sometimes it gives access violation... bug is fixed in D3.

This are the barebones I guess :

Use properties as eg. DropTarget for getting it finished
procedure TForm1.ListView1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
 If (Sender as TListView) = listview1 then Accept := true
  else accept := false
end;

procedure TForm1.ListView1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
 if (sender as TListview)=Listview1 then begin
  // do your drop stuff here.

 end;
end;

Regards, Zif.
0
 
ZifNabCommented:
oops, has to be :

procedure TForm1.ListView1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
 Accept := ((Source as TListView) = listview2);
end;

procedure TForm1.ListView1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
 if (sender as TListview) and ((source as TlistView)=listview2) then begin
  // do your drop stuff here.
 end;

And now I'm gone.

Zif.
end;

0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now