Drawing an image onto a Panel control gives artefacts when resizing

前端 未结 1 955
南旧
南旧 2021-01-18 07:06

Currently I\'m trying to do what I thought would be a simple task:

Draw an image onto the full area of a Panel control in Windows Forms. (Please ign

相关标签:
1条回答
  • 2021-01-18 07:51

    The reason for the artefacts is that the entire surface isn't redrawn when the form is resized; only the necessary parts are. The generally best solution is what you don't want to do, calling Invalidate on each resize. However, if this is in fact your situation, just use a PictureBox instead. If it's not, you might consider overriding OnPaint in your form instead, and using this.SetStyle(ControlStyles.ResizeRedraw, true) to do this automatically.

    0 讨论(0)
提交回复
热议问题