I have a picture box with a loaded image. I have 2 ways I want to draw circles on the image. The first is by clicking on the image with the mouse. Once the mouse click fires, it stores the points to the database and draws the circle. This works Fine.
Private Sub InjectionSites_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles FaceImage.MouseClick
Dim sSql As String
Dim MyPoint As New Point
MyPoint.X = e.X
MyPoint.Y = e.Y
MarkLocationOnFace(MyPoint)
sSql = "insert into Injections (x, y, custid, date, units)"
sSql = sSql & " values (" & e.X & ", " & e.Y & ", 1, '" & Now() & "', 2)"
Conn.Execute(sSql)
End Sub
Private Sub MarkLocationOnFace(ByVal myPoint As Point)
Dim p As New System.Drawing.Pen(Brushes.Black, 4)
Dim g As System.Drawing.Graphics
g = FaceImage.CreateGraphics
g.DrawEllipse(p, myPoint.X, myPoint.Y, 10, 10)
End Sub
The second, I want to recall the points that were stored to the database and plot them back to the image as they were originally drawn. It appears the subroutine is working, but once the picturebox appears, the circles are not on the image.
Private Sub LoadPreviousVisit(ByVal MyDate As Date, ByVal CustID As Decimal)
Dim sSql As String
Dim rs As New ADODB.Recordset
Dim mypoint As New Point
sSql = "Select * from Injections where CustID = " & CustID
sSql = sSql & " and CONVERT(VARCHAR(10),date,101) = '"
sSql = sSql & MyDate.ToString("MM/dd/yyyy") & "'"
rs.Open(sSql, Conn)
Do While Not rs.EOF
mypoint.X = rs("X").Value
mypoint.Y = rs("Y").Value
MarkLocationOnFace(mypoint)
rs.MoveNext()
Loop
FaceImage.SendToBack()
End Sub
What I have tried:
Sending the Picture box to the back does not appear to work either.