HOW TO SELECT ROW FROM WINFORMS LISTVIEW IN C#

Total Post:119

Points:835
C# 
C#
 1956  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. 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();
        }

      Modified On Mar-30-2018 05:12:34 AM

Answer

NEWSLETTER

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