开发者

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 beat开发者_如何学JAVAen 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());
    }
}


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.


"I realize this sounds very dubious, as the common controls have been beaten to death the world over."

ListView hasn't quite been beaten to death but it's on life support. Use a different control.


is it a custom list view (overriding drawing ?) by the way, I faced (from what I understand) the same issue with a custom Listbox and found some help here :

http://aviationxchange.net/wikis/winforms/net-color-listbox.aspx (end of the document).

Hope this could help.


I was facing the same problem but I think I found the cause: I use a tool that allows you to configure the mouse buttons (X-Mouse Button Control). By disabling it, the problem disappeared like magic.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜