Search code examples
c#listviewcontextmenustrip

Finding the selected item of list view


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.


Solution

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

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

    lvFiles is the ListView.