Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   How to remove specific item from listView (http://www.go4expert.com/forums/remove-specific-item-listview-t4134/)

shah123 4May2007 15:10

How to remove specific item from listView
 
I am trying to remove item from ListView but when i click on remove it doesnt remove the last item or in the middle but when i select the first item it removes.

How is it possible to remove any selected item in the list?

Code:

private void removeBtn_Click(object sender, EventArgs e)
        {
           
            for (int i = scheduleListView.SelectedItems.Count - 1; i >= 0; i--)
            {
                if (scheduleListView.Items[i].Selected)
                {
                    scheduleListView.Items.Remove(scheduleListView.Items[i]);
                }
            }

        }

Thanks

shah123 4May2007 15:35

Re: How to remove specific item from listView
 
while (scheduleListView.SelectedItems.Count > 0)
{
scheduleListView.Items.Remove(scheduleListView.Sel ectedItems[0]);
}

It worked . Thanks anyway


All times are GMT +5.5. The time now is 19:59.