[英]Rearranging multiple selected listview items after user finishes drag & drop
I am working on a drag and drop feature of the listview. 我正在使用listview的拖放功能。 I am stuck at the last step -> rearranging multiple selected items after user finishes drag and drop.
我停留在最后一步->在用户完成拖放操作后重新排列多个选定的项目。
Can you explain me the algorithm that implements item rearrangment? 您能解释一下实现项目重排的算法吗?
I have the index of the clicked item after user releases the mouse. 用户释放鼠标后,我具有单击项的索引。 I have indexes of dragged items and their count.
我有被拖动物品及其数量的索引。 Pseudo code is acceptable as well, but be warned that I might have follow up questions.
伪代码也是可以接受的,但请注意,我可能会有后续问题。
NOTE: 注意:
This post has been edited in response to the comments that claimed my original question did not seek user friendly implementation. 这篇帖子已经过修改,以回应声称我的原始问题未寻求用户友好实现的评论。
The point is to implement standard drag & drop behavior, and the reason I phrased my question poorly at the first place was my lack of experience with this topic. 关键是要实现标准的拖放行为,而我之所以不好说这个问题,是因为我对该主题缺乏经验。
If further clarifications are required I will update my post. 如果需要进一步说明,我将更新我的帖子。
Regards. 问候。
Normal drag & drop reordering removes the selected items and reinserts them in the new spot. 常规拖放重新排序将删除所选项目,并将其重新插入新位置。 It would be pretty unintuitive for the existing items in the new spot to jump to where the old ones came from.
让新地点中的现有物品跳到旧物品的来源是很不直观的。
To implement "standard" reordering, basically you: 要实施“标准”重新排序,基本上,您可以:
5
(assuming the new items are to be inserted above Item 6) 5
(假设要在第6项上方插入新项) LVM_DELETEITEM
LVM_DELETEITEM
一次从列表中删除拖动的项目 2
using the examples above. 2
。 2
, then the next at 3
and so on. 2
,然后将下一个插入位置3
,依此类推。 Also note you need special handling for the case where the items are dragged to the top of the list. 还要注意,对于将项目拖到列表顶部的情况,您需要进行特殊处理。 In that case, you would start the insertion at
0
, then 1
and so on. 在这种情况下,您可以从
0
开始插入,然后从1
,依此类推。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.