0
我想刪除ListView中除第一列以外的整個ListViewItems。我有一個方法,但它有時拋出ArgumentRangeException,我無法找到原因。刪除第一列以外的整個ListViewItems
private void ListViewClear()
{
for (int i = 0; i < lstKullanicilar.Items.Count; i++)
{
if (lstKullanicilar.Items[i].SubItems.Count != 1)
{
lstKullanicilar.Items[i].SubItems.RemoveAt(1);
lstKullanicilar.Items[i].SubItems.RemoveAt(2);
lstKullanicilar.Items[i].SubItems.RemoveAt(3);
lstKullanicilar.Items[i].SubItems.RemoveAt(1);
lstKullanicilar.Items[i].SubItems.RemoveAt(1);
}
}
項目[我]還沒有得到一個屬性計數,所以我改變了這樣> lstKullanicilar.Items [i] .SubItems.Count> 1和你的代碼工作。 –
非常感謝。 –