试一下
function SortItem(Item1, Item2: TListItem; ParamSort: integer): integer; stdcall;
begin
Result := item1.Index - item2.index;
end;
procedure TForm1.ListView1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := true; // 测试没加判断
end;
procedure TForm1.ListView1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
Listitem: TListItem;
i: integer;
begin
with ListView1 do
begin
i := GetItemAt(X, Y).Index;
Listitem := Items.Insert(i);
Listitem.Assign(Selected);
Selected.Delete;
Checkboxes := false;
CustomSort(@SortItem, 0);
end;
end;