for (int i = listView1.SelectedItems.Count - 1; i >= 0; i--)
{
     ListViewItem item =listView1.SelectedItems[i];
     listView1.Items.Remove(item);
}
listView1.Refresh();

解决方案 »

  1.   

    报错啊,myListBox4.SelectedItems[i];为Object类型,缺少强制转换
      

  2.   

    for(int i=LVCompany.Items.Count - 1; i >= 0;i--)
    {
    if (this.LVCompany.Items[i].Checked == false)      
    continue;
    this.LVCompany.Items[i].Remove();
    }
    这个是根据是否选中为条件来进行删除的
      

  3.   

    this.listView1.BeginUpdate();
                if (this.listView1.Items > 0)
                {
                    foreach (ListViewItem item in this.listView1.SelectedItems)
                    {
                        this.listView1.Items.Remove(item);
                    }
                }
                this.listView1.EndUpdate();
    或直接            this.listView1.SelectedItems.Clear();
      

  4.   

    if (this.myListBox.SelectedItems != null && this.myListBox.SelectedItems.Count != 0)
                {
                    this.myListBox.Items.Remove(this.myListBox.SelectedItems[0]);
                }
      

  5.   

    for (int i = this.myListBox.Items.Count - 1; i >= 0; i--)
                {
                    if (this.myListBox.GetSelected(i))
                    {
                        this.myListBox.Items.RemoveAt(i);
                    }
                }
    安心用吧,关键点在于倒序
      

  6.   

    是不是这个异常:
    System.InvalidOperationException
    Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead.
    ?WPF,System.Windows.Controls(not Forms).ListBox/ListView?是的话,就往下看(这里我用ListView, ListBox应该也差不多)。假定ListView里每一行对应一个MyItem,MyCollection 定义如下:
    public class MyCollection: ObservableCollection<MyItem>如果想remove,像这样(myListView 是一个ListView对象):ICollectionView view = (ICollectionView)CollectionViewSource.GetDefaultView(myListView.ItemsSource);
    MyCollection items = (MyCollection)view.SourceCollection;
    items.RemoveAt(...); // 或者Remove() ...
      

  7.   

    这两个帖子好象重复了:http://topic.csdn.net/u/20070823/15/7f701696-5191-4260-8505-fc6dff2f53b5.html?seed=1311380912
      

  8.   

                if (listView1.Items.Count == 0)
                {
                    MessageBox.Show("未发现!", "提示");
                    return;
                }
                else
                {
                    if (listView1.SelectedItems.Count == 0)
                    {
                        MessageBox.Show("Please select!", "Attention");
                        return;
                    }
                }
                if (listView1.SelectedItems.Count != 0)
                {
                    foreach (ListViewItem lv in listView1.SelectedItems)
                    {                    this.listView1.Items.Remove(lv);
                    }
                }