PaintEvent not overpainting

前端 未结 3 1980
北荒
北荒 2021-01-21 23:37

I have a Windows Forms application in C# with drawing panel and a button - for drawing a line.

When you click the button, you can draw a line for 2 random points.

3条回答
  •  醉梦人生
    2021-01-21 23:54

    1. You need to trigger a repaint event after the mouse is let go. Just call drawPanel.Invalidate() to cause the form to be redrawn.

    2. To draw multiple lines, you'll have to store the information for each one in a list or something, and draw each line in your repaint. The Paint method basically starts with a blank space each time, so it will only draw the most recent the way you currently have it set up.

提交回复
热议问题