Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrolling ListView with mouse wheel occasionally negates scroll

I'm having some trouble with the Win32 listview, and I hope someone has some wisdom. When scrolling very quickly (via the wheel), occasionally, the listview appears to scroll, only to jump back to the selected item so it is in-view. In other words, the list undoes your wheel scroll to show you the selected item at the top/bottom of the list. I realize this sounds very dubious, as the common controls have been beaten to death the world over.

Here's how you can replicate:

  1. Load up a listview in report mode with about 500 items or so (exact count doesn't matter, you just want several screens of data).
  2. Select an item in the list and remember what you selected.
  3. Rapidly scroll the list with the wheel downwards (toward you). We're trying to scroll the selected item out of view as fast as possible. You probably have to use more force than you usually use on the wheel. This won't always happen. You may have to try several times.
  4. Either the scroll will complete normally, or it will change its mind at the end and pull you back to a view where the selected item is on the screen.

This happens with both regular and virtual listviews. I've tested Win32 and C# on Windows 7 Ultimate.

I made a small WinForms app that exhibits the behavior (requires .NET Framework 3.5). If you'd rather not run arbitrary executables from strangers (I understand), make a new WinForms app, drop a listview in report mode in, add a column, and populate the list in the form load event with 500 increasing integers:

private void Form1_Load(object sender, EventArgs e)
{
    for (int i = 0; i < 500; i++)
    {
        this.listView1.Items.Add(i.ToString());
    }
}
like image 754
Matt Green Avatar asked Nov 26 '22 21:11

Matt Green


1 Answers

I've noticed this behavior and it does seem to be built into the list view control. I can't see any reason why the functionality would be useful. I created a thread on this at Sysinternals Forums a while back. It might be useful.

like image 199
wj32 Avatar answered Nov 28 '22 11:11

wj32