I have a rubber band that captures the cursor. How can I scroll a panel if the cursor reaches the edge of the panel? Let me know if you need more info, I think it explains itself.
Asked
Active
Viewed 541 times
1 Answers
1
You need to use the MouseMove event and check if the button is down and the cursor is located close to the edge of the panel. Say within 5 pixels. Enable a timer if that's the case, it should tick at ~200 msec. In the Tick event handler adjust the panel's AutoScrollPosition property to make it scroll.
Keep in mind that the effective mouse position is e.Location plus AutoScrollPosition.

Hans Passant
- 922,412
- 146
- 1,693
- 2,536
-
how would you adjust the AutoScrollPosition? AutoScrollPosition.X += 10 or something? – TimCodes.NET Feb 21 '11 at 15:45
-
Yes, roughly. That code won't compile but you've got the idea. Negative values cause scrolling. Set AutoScrollMinSize if necessary to make the scroll bars appear. – Hans Passant Feb 21 '11 at 16:07