SCREEN FLICKERING WHEN I ADDED ICON IN WINFORM USING DRAWING IN VB.NET

my problem is
when i added icon inside
win form
using graphics

it is added successfully
but when
I run the program
the project
as well as the desktop
sceen starts to
flicker

what is the problem and how to eradicate this
please solve

i have attached the code
Private Sub frm_List_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
     
        PaintObj(e)

    End Sub
 Private Sub PaintObj(ByVal e As PaintEventArgs)
      

        Me.Icon = New System.Drawing.Icon("D:\new\Calculate\Calculate\Resources\setup.ico")
        Dim graphics As Graphics = e.Graphics

        Dim pen As New Pen(Color.Chocolate)

        graphics.DrawRectangle(pen, 10, 10, 200, 100)
        graphics.DrawLine(pen, 0, 40, 10, 100)
        graphics.DrawIcon(Icon, 30, 100)





    End Sub

Open in new window

LVL 1
code_meAsked:
Who is Participating?
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Try like this:
Public Class frm_List_Paint

    Private Sub frm_List_Paint_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Icon = New System.Drawing.Icon("D:\new\Calculate\Calculate\Resources\setup.ico")
    End Sub

    Private Sub frm_List_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        PaintObj(e)
    End Sub

    Private Sub PaintObj(ByVal e As PaintEventArgs)
        Dim G As Graphics = e.Graphics
        G.DrawRectangle(Pens.Chocolate, 10, 10, 200, 100)
        G.DrawLine(Pens.Chocolate, 0, 40, 10, 100)
        G.DrawIcon(Me.Icon, 30, 100)
    End Sub

End Class

Open in new window

0
 
code_meAuthor Commented:
thanKs
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.