Finding the selected item of list view

instigator picture instigator · Nov 28, 2008 · Viewed 27.1k times · Source

I currently have a list view which has several rows of data and I have a contextmenustrip in C# .NET.

What I am having problems with is when you click on the menu strip item I want to know which row has been selected.

Answer

netadictos picture netadictos · Nov 28, 2008

To get selected rows as sindre says you do like this:

foreach (ListViewItem item in lvFiles.SelectedItems)
{
....................................
}

lvFiles is the ListView.