用鼠标拖动交换任意两个节点:
procedure TForm1.ListView1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
if source is TListItem then
Accept := true;
end;
procedure TForm1.ListView1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
destItem: tlistitem;
srcItem: tlistitem;
begin
srcItem := ListView1.GetItemAt(x, y);
destItem := ListView1.Items.Insert(srcItem.Index);
destItem.Assign(ListView1.ItemFocused);
caption := destItem.Caption;
ListView1.DeleteSelected;
end;