同时滚动两个面板c# winForms
是的,所以我有两个宽度相同且数据宽度相同的面板。顶部面板启用了自动滚动。我希望能够使用顶部面板滚动条滚动两个面板。这意味着底部面板没有滚动条。我该怎么做呢?
替代文本 http://members.multimania.co.uk/jeff1524/pics/ scrolling.jpg
编辑:我尝试了 panel2.AutoScrollPosition = panel1.AutoScrollPosition;
没有
我也
e.Graphics.DrawRectangle(new Pen(Color.Pink,3), 10, 10, 30, 20);
e.Graphics.TranslateTransform(panel1.AutoScrollPosition.X, 0);
尝试在矩形上进行任何移动。 我做错了什么?
yea so I have 2 panels with the same width and the same width of data in them. the top panel has autoscroll enabled. I would like to be able to scroll both panels, with the top panel scrollbar. which means that the bottom panel doesn't have a scroll bar. How would I do that?
alt text http://members.multimania.co.uk/jeff1524/pics/scrolling.jpg
EDIT: I tried panel2.AutoScrollPosition = panel1.AutoScrollPosition;
nothing
I also tried
e.Graphics.DrawRectangle(new Pen(Color.Pink,3), 10, 10, 30, 20);
e.Graphics.TranslateTransform(panel1.AutoScrollPosition.X, 0);
no movement on the rectangle.
What am i doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简单易行。为第一个面板实现 Scroll 事件,并使其在第二个面板上 Invalidate()。使用第一个面板的滚动位置在第二个面板的 Paint 事件中绘制文本:
Easy peasy. Implement the Scroll event for the 1st panel and have it Invalidate() the 2nd. Draw the text in the 2nd panel's Paint event, using the scroll position of the 1st:
甚至更容易。
只需将面板放置在另一个具有滚动条的面板中(AutoScroll = true)。
我就用过这个策略。
Even easier.
Just place the panels inside another panel that has the scroll bar (AutoScroll = true).
I've used this strategy.