如何在Panel中制作滚动条?
我有一个面板,它画了不同的图形项目。
如何在不使用 win api 的情况下滚动。
如果面板添加到控件,但如果您刚刚绘制不起作用=(
编辑:
工作,但宽度和高度需要手动,我该怎么办
protected override void OnScroll(ScrollEventArgs se)
{
base.OnScroll(se);
if (se.ScrollOrientation == ScrollOrientation.VerticalScroll)
{
foreach (Platform platform in m_arPlatforms)
{
platform.ReLocation(platform.Location.X, platform.Location.Y + (se.OldValue - se.NewValue));
}
}
if (se.ScrollOrientation == ScrollOrientation.HorizontalScroll)
{
foreach (Platform platform in m_arPlatforms)
{
platform.ReLocation(platform.Location.X + (se.OldValue - se.NewValue), platform.Location.Y);
}
}
}
I have a Panel, it painted a different Graphics items.
How to scroll without using win api.
Do I get to do if the panel added to Controls, but if you just painted does not work = (
EDIT:
Work, but width and heigth required manul
protected override void OnScroll(ScrollEventArgs se)
{
base.OnScroll(se);
if (se.ScrollOrientation == ScrollOrientation.VerticalScroll)
{
foreach (Platform platform in m_arPlatforms)
{
platform.ReLocation(platform.Location.X, platform.Location.Y + (se.OldValue - se.NewValue));
}
}
if (se.ScrollOrientation == ScrollOrientation.HorizontalScroll)
{
foreach (Platform platform in m_arPlatforms)
{
platform.ReLocation(platform.Location.X + (se.OldValue - se.NewValue), platform.Location.Y);
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如您在这里看到的:面板类,该面板派生自 ScrollableControl,只需将 AutoScroll 属性设置为 true 即可工作。
as you can see here: Panel Class, the panel derives from
ScrollableControl
, just set to true theAutoScroll
property and it will work.我不确定我完全理解你的问题,但假设你的 AutoScroll 工作正常,并且你的问题是你自己的绘画代码没有考虑滚动,那么它就像使用 .AutoScrollPosition 调用 .TranslateTransform 一样简单坐标。
I'm not sure I understand your question completely, but provided that you have the AutoScroll working correctly and your problem is that your own painting code is not taking the scrolling into account, then it is as easy as calling .TranslateTransform with the .AutoScrollPosition coordinates.