I am quite new to the Dragging and Dropping System in Delphi for ListView. I found a simple solution on the internet to drag and drop items in ListView. The problem is that the code shows only dragging the first column and I want to show and drag the entire row.
You can view in the following picture what I get and what I want to get.
procedure TForm1.ListView1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
DragItem, DropItem, CurrentItem, NextItem: TListItem;
begin
if Sender = Source then
with TListView(Sender) do
begin
DropItem := GetItemAt(X, Y);
CurrentItem := Selected;
while CurrentItem <> nil do
begin
NextItem := GetNextItem(CurrentItem, SdAll, [IsSelected]);
if DropItem = nil then DragItem := Items.Add
else
DragItem := Items.Insert(DropItem.Index);
DragItem.Assign(CurrentItem);
CurrentItem.Free;
CurrentItem := NextItem;
end;
end;
end;
procedure TForm1.ListView1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := Sender = ListView1;
end;
self.ListView1.DragMode := dmAutomatic;