listview item 拖拽

procedure TForm1.lv1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
aItem, bItem: TListItem;
begin
if(Source is TListView) then
begin
bItem := (Source as TListView).Selected;

ShowMessage(IntToStr(bItem.Index));

aItem:=(Source as TListView).Items.Insert
((Source as TListView).Items.IndexOf((Source as TListView).GetItemAt(X,Y)));
aItem.Assign(bItem);
(Source as TListView).Selected.Delete;
aItem.Selected := True;
ShowMessage(IntToStr(aItem.Index));
end;
end;


procedure TForm1.lv1DragOver(Sender, Source: TObject; X, Y: Integer; State:
TDragState; var Accept: Boolean);
begin
Accept := True;
end;

posted @ 2019-12-25 15:42  绿水青山777  阅读(351)  评论(0编辑  收藏  举报