Search code examples
c#.netwinformslistview

ListView Item select in winform


I want to select item in a ListView upon clicking. I also want to know what I clicked. I work on winforms with c#.I also want to know How I can clicking the all row?


Solution

  • Just handle the Click event on the list and use the ListView.SelectedItems property to get what items are selected:

    private void listView1_Click(object sender, EventArgs e)
    {
        var firstSelectedItem = listView1.SelectedItems[0];
    }