将所有选定的项目从 ListView1 复制到 ListView2
如何将多个项目从 TListView 复制到另一个。现在我这样做:
procedure TForm1.CopyToRightClick(Sender: TObject);
var
selected: TListItem;
addItems: TListItem;
begin
saveChanges.Visible := false;
selected := deviceList.Selected;
addItems := selectedDevicesList.Items.Add;
addItems.Assign(selected);
end;
但这样只有一个选定的项目被复制。有没有办法复制所有选定的项目?
How to copy multiple items from TListView to another. Right now im doing it like this:
procedure TForm1.CopyToRightClick(Sender: TObject);
var
selected: TListItem;
addItems: TListItem;
begin
saveChanges.Visible := false;
selected := deviceList.Selected;
addItems := selectedDevicesList.Items.Add;
addItems.Assign(selected);
end;
But this way only one selected item get copied. Is there a way to copy all selected items?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将
ListView1
中的每个选定列表视图项目复制到ListView2
。您可以将
ListView1
中的每个选定列表视图项目移动到ListView2
。(这在中等大小的列表中效果很好。在较大的列表中,当您需要对每个选定的项目执行某些操作时,迭代所有项目并检查
Selected
属性太慢了。相反,您应该将while
循环与GetNextItem
和isSelected
结合使用。)You can do
to copy every selected list view item in
ListView1
toListView2
.You can do
to move every selected list view item in
ListView1
toListView2
.(This works well in moderately-sized lists. In larger lists, when you need to do something for every selected item, iterating over all items and checking the
Selected
property is way too slow. Instead, you should use awhile
loop withGetNextItem
withisSelected
.)