foreach (Student student in liststu)
{
listBox1.Items.Add(student.ToString());
}
foreach (Staff staff in liststa)
{
listBox1.Items.Add(staff.ToString());
}
我有两个arraylist liststa
liststu
用于填充我的列表框。我试图从列表框和arrylist中同时删除,我正在尝试使用Remove()
,但我不知道如何从列表框中获取正确的值以便在arraylist中删除。删除相同的值列表框和阵列列表
for (int i = listBox1.SelectedIndices.Count - 1; i >= 0; i--)
{
listBox1.Items.RemoveAt(listBox1.SelectedIndices[i]);
liststa.Remove(listBox1.SelectedIndex.ToString());
}
我如何从列表框中的使用ArrayList的Remove()
之前从ArrayList中删除其给出错误“索引超出了数组的范围。”我之前列表框位置试试这个和ArrayList的位置是不同的,我认为是因为IM加载另一个列表中列出框也 – 2014-12-05 19:58:56
删除由字符串较好地解决了我 – 2014-12-05 20:02:37