0

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?

JohnSaps
  • 602
  • 5
  • 16
  • 1
    Looks like a [common](https://stackoverflow.com/questions/25709069/the-maximum-number-of-characters-a-textbox-can-display/25709337?r=SearchResults&s=9|13.6013#25709337) winforms limitation.. – TaW Mar 14 '21 at 09:19
  • 2
    The bigger question is why you have a ListView with such an unusual height –  Mar 14 '21 at 10:00
  • This a scrollable event logger. Not having to load the data from e.g. the database on the fly makes it smoother. – JohnSaps Mar 14 '21 at 11:02
  • 1
    Well I'm sure you could store them in memory and only display a smaller amount of data.. – TaW Mar 14 '21 at 13:31
  • OK, I'll accept the explanation of it being a common Winforms limitation. TaW, please make it as an answer. And thanks everybody. – JohnSaps Mar 16 '21 at 05:43

0 Answers0