我这里的困难是这样的,我有两个 listview,
分别为listview1和listview2,
listview2中的item项,是从listview1 中得来的,现在我按ctrl 然后点鼠标,选中listview1中的item(是选了多项)然后在
listview2中add相对应的项·可是,无论我怎么做,listview2中,ITEM生成的顺序,同listview1中的顺序一样,而不是我选择的顺序………… 这是我的代码for(int p=0;p<this.lvbill.SelectedItems.Count;p++)
{
//
int z=int.Parse(this.lvbill.SelectedIndices[p].ToString()); CeratMove(z);
}
CeratMove(int i)是我对应的,生成listview2中item的方法!
分别为listview1和listview2,
listview2中的item项,是从listview1 中得来的,现在我按ctrl 然后点鼠标,选中listview1中的item(是选了多项)然后在
listview2中add相对应的项·可是,无论我怎么做,listview2中,ITEM生成的顺序,同listview1中的顺序一样,而不是我选择的顺序………… 这是我的代码for(int p=0;p<this.lvbill.SelectedItems.Count;p++)
{
//
int z=int.Parse(this.lvbill.SelectedIndices[p].ToString()); CeratMove(z);
}
CeratMove(int i)是我对应的,生成listview2中item的方法!
0 Item1 未选定
1 Item2 已选定
2 Item3 未选定
3 Item4 已选定
4 Item5 已选定 基于前一个表中的 ListView.ListViewItemCollection 示例,下表说明 ListView.SelectedIndexCollection 将如何显示。索引 ListViewItemCollection中选定项的索引
0 1
1 3
2 4 知道是为什么了吗?
0 Item1 未选定
1 Item2 已选定
2 Item3 未选定
3 Item4 已选定
4 Item5 已选定 基于前一个表中的 ListView.ListViewItemCollection 示例,下表说明 ListView.SelectedIndexCollection 将如何显示。索引 ListViewItemCollection中选定项的索引
0 1
1 3
2 4 知道是为什么了吗?
ListViewItem lvi = listview1.FocusedItem;//判断listview2中是否已存在
foreach(ListViewItem i in this.listview2.Items)
{
if(i.Tag == lvi.Tag)
return;
}
//如果两个listview的结构一致,可以直接加:
listview2.Items.Add(lvi);