|One way is to use
ListView.GetItemAt to get the
ListViewItem that was clicked, then enumerate the
ListView.Columns collection and compare the x-coordinate with the incremental
ColumnHeader.Width property (i.e., incrementally add the width of the
ColumnHeaders as you enumerate and see if the x-coordinate falls within the start and end x-coordinates of the column.
Another way is to override
WndProc in a derivative class, define the
NMITEMACTIVATE structure, and use the
iSubItem members of the struct. For more information, see the Platform SDK for the
LVN_CLICK notification message and the
NMITEMACTIVATE structure (includes the
NMHDR structure, which you can simply merge the members of into the
NMITEMACTIVATE struct if you don't plan on using the
NMHDR struct elsewhere).
Microsoft MVP, Visual C#