Reputation: 15378
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);
}
}
}
Upvotes: 0
Views: 2409
Reputation: 9244
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.
Upvotes: 0
Reputation: 44595
as you can see here: Panel Class, the panel derives from ScrollableControl
, just set to true the AutoScroll
property and it will work.
Upvotes: 1