ListView Scrolling
-
Hello, I'd like to know if a user scrolls my ListView, since .NET (weird?) doesn't support this. Now I've found several articles (on Google) which tell me I need to create a Virtual ListView and override WndProc. I've done this but: 1) The control is terribly slow, and I can't just drag it on the form, meaning I need to create it in code. Is there any easy way to check if a NORMAL ListView gets scrolled? I also need to know the difference between Scrolling Up, and Scrolling Down. Please help me out, Zaegra
Motivation is the key to software development.
-
Hello, I'd like to know if a user scrolls my ListView, since .NET (weird?) doesn't support this. Now I've found several articles (on Google) which tell me I need to create a Virtual ListView and override WndProc. I've done this but: 1) The control is terribly slow, and I can't just drag it on the form, meaning I need to create it in code. Is there any easy way to check if a NORMAL ListView gets scrolled? I also need to know the difference between Scrolling Up, and Scrolling Down. Please help me out, Zaegra
Motivation is the key to software development.
Talking about WPF or WinForms? For WPF, I think you can just hook the ScrollViewer.ScrollChanged event, and you're golden... As for WinForms... Never noticed they didn't have an event for that... Well, you could catch the various mouse events, and look for changes in the TopItem property... Bit easier than hooking WndProc, but not as direct.
Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)
-
Talking about WPF or WinForms? For WPF, I think you can just hook the ScrollViewer.ScrollChanged event, and you're golden... As for WinForms... Never noticed they didn't have an event for that... Well, you could catch the various mouse events, and look for changes in the TopItem property... Bit easier than hooking WndProc, but not as direct.
Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)
Using WinForms :-\ But I don't care about the internal layout of the Listview, I only need to know if a listview has focus, if the scrollwheel is scrolled. And if so, if it was scrolled up or down.. Can't seem to find anything fitting this purpose. Any ideas on this?
Motivation is the key to software development.
modified on Tuesday, October 13, 2009 2:24 PM
-
Using WinForms :-\ But I don't care about the internal layout of the Listview, I only need to know if a listview has focus, if the scrollwheel is scrolled. And if so, if it was scrolled up or down.. Can't seem to find anything fitting this purpose. Any ideas on this?
Motivation is the key to software development.
modified on Tuesday, October 13, 2009 2:24 PM
Well, if TopItem changes, it means it was scrolled... TopItem is the first item visible... Figuring out the direction would require knowing the content, though. On the other hand, if you're specifically looking for the mousewheel... There IS a MouseWheel event :)
Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)
-
Using WinForms :-\ But I don't care about the internal layout of the Listview, I only need to know if a listview has focus, if the scrollwheel is scrolled. And if so, if it was scrolled up or down.. Can't seem to find anything fitting this purpose. Any ideas on this?
Motivation is the key to software development.
modified on Tuesday, October 13, 2009 2:24 PM
Hi, For mousewheel actions, there is a MouseWheel event. However there probably are other ways to cause a scroll which you also would like to get (for consistency if nothing else), such as clicking in the scroll bar parts, using the arrow keys, maybe performing a find on the content, etc. Therefore I would be inclined to use the Paint event: just add a handler to Paint, and compare TopIndex to its previous value. You will get some redundant events (e.g. when uncovering part of the Form), but that would be OK I guess. BTW: I said "add a handler", not "override OnPaint", as you still want the original painting to occur. :)
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!