---
title: "Remove selected rows from multi-column listView in C#"  
description: "Remove selected rows from multi-column listView in C#"  
author: "Anonymous User"  
published: 2013-07-17  
updated: 2013-07-17  
canonical: https://www.mindstick.com/forum/1300/remove-selected-rows-from-multi-column-listview-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Remove selected rows from multi-column listView in C#

Hi [Developers](https://www.mindstick.com/articles/12875/blunders-you-must-avoid-while-hiring-java-developers-to-get-the-best-fulfilling-your-needs)!

I have a [listview](https://www.mindstick.com/articles/12744/listview-in-android) with two columns and I'm using a [context](https://www.mindstick.com/forum/23245/what-is-context-in-android) menu to allow [users](https://www.mindstick.com/news/2244/issue-preventing-users-from-accessing-facebook-s-social-networking-platforms-has-been-resolved) to [remove](https://yourviews.mindstick.com/story/4554/8-harmful-weeds-to-remove-from-garden) selected rows. To remove the selected rows, I've tried with the following [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) but it doesn't work:

[private](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) void toolStripMenuItem1_Click(object sender, EventArgs e)

{

listView1.SelectedItems.Clear();

}

I suspect this is because the listview has two columns, but I can't [figure](https://yourviews.mindstick.com/view/87536/what-are-ghosts-jobs-and-how-to-figure-out-them) out a solution to remove selected rows. Removing all rows works with: listView1.Items.Clear();.

Thanks in [Advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)

## Replies

### Reply by shreesh chandra shukla

Solution!

The latest example of BeefTurkey looks correct, but he should decrement the variable i after removing a selected item:

```
for (int i = 0; i < listView1.Items.Count; i++ ){    if
(listView1.Items[i].Selected)    {       
listView1.Items[i].Remove();        i--;    }}
```

The index of items larger as I is decremented by 1 after the removal. So you should reposition i to match the next not tested item.


---

Original Source: https://www.mindstick.com/forum/1300/remove-selected-rows-from-multi-column-listview-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
