Listview SubItem ClickEvent

flashkid10

Member
Joined
Dec 9, 2016
Messages
16
Programming Experience
Beginner
I'm current creating an app (POC) that list events, and it is going to have a weekly view (Sun-Sat). when you click on a cell it will do something; I want to send a number at a method called "ShowDetails(int x), how would I tag a number onto a subitem and have it send it when the subitem is clicked. I am currently displaying the event onto a listview with nine rows in each of the seven columns. how would i achieve this?
 
Firstly, if you're not using any view other than Details and not using groups then you shouldn't be using a ListView at all. You should be using a DataGridView, in which case you can simply handle the CellClick event.

If you insist on misusing a ListView or must use it then life is not so easy. You would have to handle the MouseClick event of the control, get the mouse pointer position, call HitTest and then use the ListViewHitTestInfo returned to get the subitem if there is one. You can then get a value from the Tag property of the subitem, where you put it when you created the subitem in the first place.
 

Latest posts

Back
Top Bottom