C#: Windows Forms: What could cause Invalidate() to not redraw?

前端 未结 3 1740
无人共我
无人共我 2020-12-31 08:56

I\'m using Windows Forms. For a long time, pictureBox.Invalidate(); worked to make the screen be redrawn. However, it now doesn\'t work and I\'m not sure why.

3条回答
  •  春和景丽
    2020-12-31 09:19

    Invalidate or Refresh will do the same thing in this case, and force a redraw (eventually). If you're not seeing anything redrawn (ever), then that means either nothing has been drawn at all in DrawWorldBox or whatever has been drawn has been drawn off the visible part of the PictureBox's image.

    Make sure (using breakpoints or logging or stepping through the code, as you prefer) that something is being is being added to selectionRectangles, and that at least one of those rectangles covers the visible part of the PictureBox. Also make sure the pen you're drawing with doesn't happen to be the same color as the background.

提交回复
热议问题