Hi all,
Im trying to enlarge a circle on a form using a scrollbar. I have managed to do this using the following code:
Thing is the code draws a circle on every scroll movement. You end up with a mass of circles. I want it to clear previous graphic and just show the circle that relates to the current scrollbar graphic, giving the impression of enlarging and shrinking. Any ideas? All help most appreciated.Code:Private Sub DrawCircle(ByVal cp As Point, ByVal radius As Integer) Dim gr As Graphics gr = Panel1.CreateGraphics Dim rect As Rectangle = New Rectangle(cp.X - radius, cp.Y - radius, 2 * radius, 2 * radius) 'gr.DrawEllipse(Pens.Black, rect) gr.DrawEllipse(Pens.Black, rect) gr.FillEllipse(Brushes.Red, rect) gr.Dispose() End Sub Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll DrawCircle(New Point(TrackBar1.Value / 2, TrackBar1.Value / 2), TrackBar1.Value) End Sub




Reply With Quote