What the issue is: I have a ListView placed on a Panel with AutoScroll set to true. When the height of the ListView gets greater than 32767 it is not possible to select an item anymore. I found out that it is related to the fact that the mouse X and Y roll over at 32767 (signed 16 bit).
What I have tried: With the following code I hoped to bypass the limitation of the 32767 limit by using MousePosition, and then select the item by code:
Point p = listView1.PointToClient(MousePosition);
ListViewItem clickedItem = listView1.GetItemAt(p.X, p.Y);
if (clickedItem != null)
clickedItem.Selected = true;
When setting a break point after "ListViewItem clickedItem = listView1.GetItemAt(p.X, p.Y);" I see that the correct item is actually found. However, the item is never selected. I simply see strange behavior like item with index 21 being selected (but not focused) instead of the clicked item, which was e.g. index 2000. It acts like an exception is being thrown internally in the ListView.
Does anyone have an idea how to select an item outside pixel 32767?