Home > DeveloperSection > Forums > How to select row from winforms listview in C#
Goti Bandu

Total Post:119

Points:835
Posted on    July-17-2013 3:30 AM

 C# C# 
Ratings:


 1 Reply(s)
 1295  View(s)
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!



shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Points:735
Posted on    July-17-2013 8:20 AM

Solution!

This should works

  private void buttonDelete_Click(object sender, EventArgs e)

    {

        //selected data is of custom type MyData

        var selected = yourListView.SelectedItems.First();

    }


Don't want to miss updates? Please click the below button!

Follow MindStick