日期:2014-05-19  浏览次数:20921 次

两个listbox,怎么写button click代码,把某一个中的某行移到另一个的最后
两个listbox,怎么写button   click代码,把某一个中的某行移到另一个的最后


------解决方案--------------------
private void button1_Click(object sender, EventArgs e)
{
int j = 0;
for (int i = listBox1.Items.Count - 1; i > = 0; i--)
{
if (listBox1.GetSelected(i))
{
listBox2.Items.Add(listBox1.Items[i]);
listBox1.Items.RemoveAt(i);
j = i;
}
}
for (; j > = 0; j--)
{
if (listBox1.Items.Count > j)
{
listBox1.SetSelected(j, true);
break;
}
}
}