Painted dots on PictureBox

ZooTV
06-29-2004, 02:54 PM
I'm loading a map in a PictureBox, and I have an array of coordinates that I have to paint on the map.

I've been using the FillEllipse method to draw a little circle on top of the PictureBox, i.e. PB.CreateGraphics.DrawEllipse(Brushes.Black, x1, y1, x2, y2).

The problem I have is that I can't find a Refresh event so that when i put something in front of the dots and put it away, they paint themselves again. I've read that there's no AutoRedraw in the .NET PictureBoxes, so I wondered what any other way around there is.

Thanks,

bear24rw
06-29-2004, 03:45 PM
you could put the PB.CreateGraphics..... thing into its own sub like

Public Sub DrawDots()
PB.CreateGraphics.DrawEllipse(Brushes.Black, x1, y1, x2, y2)
'Make sure that it is the same coordinates though!
End sub

and then after the other stuff gets erased call DrawDots() and that will redraw them

:)

ZooTV
06-29-2004, 09:30 PM
The only problem is that they get erased when the window gets minimized, or another window goes on top of the dots, or a menu goes over the dots, etc. And I don't have any idea on how to get an event for this.

Draders
06-30-2004, 12:03 AM
VB.net doesn't have autoredraw like vb6 did so you have to manually do it under the objects paint declaration.

Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint

e.Graphics. whatever graphics drawing you have to do

also e.ClipRectangle is the rectangle of the area that needs to be redrawn so you can check and only draw what you need to increase speed.

End Sub

ZooTV
06-30-2004, 07:07 AM
Thank you, I'll give it a try. :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum