如何将ListView控件选中的项向上移动或向下移动
如何将ListView控件选中的项向上移动或向下移动 C#--------------------编程问答-------------------- 代码里重新设置他们的index. --------------------编程问答-------------------- --------------------编程问答-------------------- 写代码重新设置index! --------------------编程问答-------------------- 重新设置index! --------------------编程问答-------------------- //上移
private void pictureBox_upmove_Click(object sender, EventArgs e)
{
for(int i=0;i<this.myListView_look.SelectedItems.Count;i++)
{
System.Windows.Forms.ListViewItem listViewItem = this.myListView_look.SelectedItems[i];
int index = this.myListView_look.SelectedItems[i].Index - 1;
if (index < 0) return ;
this.myListView_look.Items.Remove(this.myListView_look.SelectedItems[i]);
this.myListView_look.Items.Insert(index, listViewItem);
listViewItem.Selected = true;
}
}
//下移
private void pictureBox_downmove_Click(object sender, EventArgs e)
{
for (int i = this.myListView_look.SelectedItems.Count-1; i > -1; i--)
{
System.Windows.Forms.ListViewItem listViewItem = this.myListView_look.SelectedItems[i];
int index = this.myListView_look.SelectedItems[i].Index + 1;
if (index > this.myListView_look.Items.Count -1) return;
this.myListView_look.Items.Remove(this.myListView_look.SelectedItems[i]);
this.myListView_look.Items.Insert(index, listViewItem);
listViewItem.Selected = true;
}
} --------------------编程问答-------------------- 楼主好问题啊,我也正需要这方面资料呢,谢谢,答案出来别人贴出来,大家学习啊 --------------------编程问答-------------------- 楼主好问题啊,我也正需要这方面资料呢,谢谢,答案出来别人贴出来,大家学习啊 --------------------编程问答--------------------
支持
补充:.NET技术 , 其他语言