【发布时间】:2014-08-13 15:00:50
【问题描述】:
我编写了一个代码,将第一个选中列表框中的选定项目转移到另一个选中列表框中。这部分代码有效(但是我仍然必须找到一种方法,这样相同的选定项目就不会被一遍又一遍地写入)。我的第二个目标是从第一个选中列表框中删除选定的项目。我得到的错误是数组超出范围。
private void button_ekle_Click(object sender, EventArgs e)
{
int i = 0;
int k = 0;
i = clb_input.Items.Count;
//the number of items in the first checkedlistbox
for (k = 0; k <i; k++)
{
if (clb_input.GetItemChecked(k) == true)
{
//clb_output is the second checkedlistbox
clb_output.Items.Add(clb_input.Items[k]);
clb_input.Items.Remove(clb_input.CheckedItems[k]);
i--;
}
else { }
}
}
【问题讨论】:
标签: c# winforms checkedlistbox