HOW TO SELECT ROW FROM WINFORMS LISTVIEW IN C#

Goti Bandu

Total Post:119

Points:835
Posted by  Goti Bandu
C# 
C#
 1636  View(s)
Ratings:
Rate this:
Hi mindstick!

I have listview which is populated with list of data. Now I want to select desired row and on click button to recognize that item to delete from a collection.

Question is how to recognize selected row from the listview?

private void buttonDelete_Click(object sender, EventArgs e)

{

    //selected data is of custom type SelectedData

    var selected = (SelectedData)....?

}

Thanks in Advanced!

  1. shreesh chandra shukla

    Post:105

    Points:735
    Re: How to select row from winforms listview in C#

    Solution!

    This should works

      private void buttonDelete_Click(object sender, EventArgs e)

        {

            //selected data is of custom type MyData

            var selected = yourListView.SelectedItems.First();

        }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!