读书人

两个listbox,如何写button click代码,

发布时间: 2012-01-09 21:05:42 作者: rapoo

两个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;
}
}
}

读书人网 >C#

热点推荐