Paint on panel allowing auto scroll

前端 未结 1 922
难免孤独
难免孤独 2021-01-13 13:39

I\'m implementing an application which want to draw lines in the panel. But the panel must be auto scrolled as it size can be expand at run time. The panel paint method I ha

相关标签:
1条回答
  • 2021-01-13 14:18

    I'll assume that "get crashes" doesn't actually mean that your code crashes. You'll need to offset the drawing by the scroll amount. That's easy to do:

    private void panel1_Paint(object sender, PaintEventArgs e) {
      e.Graphics.TranslateTransform(panel1.AutoScrollPosition.X, panel1.AutoScrollPosition.Y);
      // etc
      //...
    }
    
    0 讨论(0)
提交回复
热议问题