79120737

Date: 2024-10-24 07:11:49
Score: 1.5
Natty:
Report link

You can draw based on the current scroll position, which is available through the AutoScrollPosition property of the Panel. When you scroll, the panel's position changes, so the drawing needs to shift accordingly.

Avoid excessive use of Invalidate() as it can lead to performance issues.

Draw directly on the Graphics object passed in the PaintEventArgs to manage proper scrolling behavior.

Of course as @Idle_Mind said, embedding a large enough PictureBox in a panel and adding scroll bars to the panel is a simpler solution.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • User mentioned (1): @Idle_Mind
  • Low reputation (0.5):
Posted by: Jiachen Li-MSFT