In a ListView with ID = myListView
I use in a C# Windows project, I have two columns,
and about a dozen rows, i.e., members of the ListViews Items
collection.
In determining whether a mouse was clicked inside the second
row, right column, I compute the bounding rectangle
Rectangle row2col2 = myListView.Items[1].SubItems[0].Bounds
and then check if the point returned by MouseEventsArg
falls inside the rectangle.
But for some reason, the test seems to pass whether I click in either
column, which in my case is undesired behavior. I want the test
to pass only when the right column, i.e., the one with SubItems[0].
is clicked.
Any idea what I'm doing wrong?
The motivation for the question is that I populate the SubItem
with a ComboBox. It works, but I don't want the ComboBox
to be available when the user clicks in an adjacent column.
I'm using the MouseUp event by the way, but I don't
think that's relevant.
Jeff Gaines - 10 Dec 2006 21:10 GMT
On 10/12/2006 in message
>In determining whether a mouse was clicked inside the second
>row, right column, I compute the bounding rectangle
[quoted text clipped - 3 lines]
>and then check if the point returned by MouseEventsArg
>falls inside the rectangle.
Isn't SubItems[0] the ListViewItem itself? I *think* SubItem indexing
starts at 1 for the first sub item. I suspect you are getting the ItemRect
for the whole LVItem.

Signature
Jeff Gaines
Damerham Hampshire UK