Reputation: 7590
Im capturing the Scroll event in a flowLayoutPanel that contains a bunch of controls inside (textboxes). If I move the scrollbar with the mouse the Scroll event is correctly captured. But If jump from control to control using the tab key and the scrollbar moves to give the textbox focus the event is not raised. What can I do in that situation, I really need to capture no matter how the scroll is modified.
I uploaded a simple project where the problem could be shown http://1drv.ms/1UabHkv
Upvotes: 2
Views: 759
Reputation: 8991
I don't think you are binding to the correct event. The docs for ScrollableControl.Scroll Event state:
The Scroll event occurs when the user scrolls through the client area by interacting with the scroll bars, or when the user navigates between controls and the active control scrolls into view. The Scroll event also occurs when you write code, such as setting the AutoScrollPosition property, that scrolls through the client area.
Edit:
It would seem that the MS documentation is indeed incorrect. I've tested using both your sample project and one I created and I'm experiencing the same behaviour where the Scroll
event is not firing on tab or even on mousewheel.
It would seem that the best course of action would be to implement your own scrollbars and turn Autoscroll
off for your Panel
.
See the following SO question for mroe information: How to use ScrollableControl with AutoScroll set to false
Upvotes: 0
Reputation: 1124
You're looking for the GotFocus event. There is also a LostFocus event. It works for clicks, tabs, shift+tabs, and so on
textBox1.GotFocus += textBox1_ScrollEvent;
where textBox1_ScrollEvent
is the event handler for the scrolling
Upvotes: 1