Hi Guys,
I have developed a program which continuously draws a circle using a timer. Now every time the circle gets displays it flickers and which is because i have used me.refresh. Is there any other way to avoid this flickering.
here is my code
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
Me.sweepAngle += 1
If Me.sweepAngle = 360 Then
Me.Timer1.Stop()
End If
If sweepAngle = 90 Then
change = 1
End If
If sweepAngle = 180 Then
change = 2
End If
'Me.Invalidate()
Me.Refresh()
'Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
'Me.SetStyle(ControlStyles.UserPaint, True)
'Me.SetStyle(ControlStyles.DoubleBuffer, True)
End Sub
Public Sub GroupBox1_Paint1(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles GroupBox1.Paint
Dim a As Graphics = e.Graphics
Dim mypen As Pen
mypen = New Pen(System.Drawing.Color.Black, 2)
'e.Graphics.DrawArc(Pens.Black, 10, 10, 48, 48, 0, Me.sweepAngle)
a.DrawEllipse(mypen, 660, 20, 98, 98)
e.Graphics.FillPie(Brushes.Red, 660, 20, 98, 98, -90, Me.sweepAngle)
If change = 1 Then
'e.Graphics.FillPie(Brushes.Green, 10, 20, 98, 98, -90, Me.sweepAngle)
e.Graphics.FillPie(Brushes.Orange, New Rectangle(660, 20, 98, 98), -90, 90)
End If
If change = 2 Then
e.Graphics.FillPie(Brushes.Orange, New Rectangle(660, 20, 98, 98), -90, 90)
e.Graphics.FillPie(Brushes.Green, New Rectangle(660, 20, 98, 98), 0, 90)
End If
End Sub
Thank you
Ashwin