Drawing Graphics Disappear in VB.net

后端 未结 4 1464
后悔当初
后悔当初 2021-01-21 03:39

I have a simple program that you can draw on the screen with FillEllipse and FillRectangle. My problem is that when you drag another window over even a small portion of the scre

4条回答
  •  半阙折子戏
    2021-01-21 04:23

    @SLaks already told you to do all painting in the OnPaint method. Here's a little more information. If you're trying to draw on a form, you would override the OnPaint method and do all your painting using the Graphics instance that is passed into the method. Here is more information on the topic:

    • How to use the CreateGraphics method
    • CreateGraphics. A boon or a curse?
    Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
        MyBase.OnPaint(e)
        e.Graphics.FillEllipse(Brushes.Red, Me.ClientRectangle)
    
    End Sub
    

提交回复
热议问题