how to raise an event from another one
I have two panels,开发者_运维技巧 and when the first panel is scrolled, I want the other one to be scrolled, How do I do that?
thanks in advance :).
You can listen for ScrollableControl.Scroll to find out when it's scrolling.
Unfortunately I don't know of any easy way to make the other one scroll to the correct location, but I think you should be able to do it by sending WM_VSCROLL
or WM_HSCROLL
to it using the SendMessage API function.
Depending on the contents of the panels you might also be able to "cheat" by setting AutoScroll
to true
and then whenever the first panel is scrolled, you set focus to a suitable control in the second panel that is outside the currently visible area and so make it scroll to there. But I'm not sure how well this would work or if it would be easier than doing it properly (if you always want to scroll to the extreme sides of the panel, it might be useful).
精彩评论