Handle click on a sub-item of ListView

.net, c#, user-interface, windows, winforms

Solution

You need to determine the column by its position:

private void listView_Click(object sender, EventArgs e)
{
    Point mousePos = listView.PointToClient(Control.MousePosition);
    ListViewHitTestInfo hitTest = listView.HitTest(mousePos);
    int columnIndex = hitTest.Item.SubItems.IndexOf(hitTest.SubItem);
}

Problem

How can I handle click on a sub-item of ListView (detail mode)? i.e. I need to detect what exactly column was clicked.

Original source