1
我想在pb1
(圖片框)中繪製橢圓,但橢圓的數量取決於查詢的內容。通常,它大於1.我已經在下面有一個代碼,但它只繪製一個橢圓。我想使用數組,但我不知道如何去做。任何幫助/援助將不勝感激。謝謝如何在繪圖點中創建數組
Sub getdots()
Try
Call MyConnection()
Sql = "select l.lot_no, l.lot_x, l.lot_y FROM lot_details AS l, area as a, type as t where l.type_no=t.type_no and t.AREA_NO=a.AREA_NO and [email protected] AND l.LOT_STATE='available'"
Dim cmd As New MySqlCommand(Sql, Con)
With cmd
.CommandText = Sql
.Connection = Con
.Parameters.AddWithValue("@Anum", frmvacantlots.cboareano.Text)
.ExecuteNonQuery()
End With
Dim reader As MySqlDataReader
reader = cmd.ExecuteReader
If reader.Read Then
Try
x = reader.GetString(1)
y = reader.GetString(2)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
Con.Close()
End Sub
Private Sub pb1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pb1.Paint
e.Graphics.FillEllipse(Brushes.Red, x - 5, y - 5, 10, 10)
getdots()
End Sub
將'getdots'的結果存儲在Point對象列表中。然後在Paint中,在列表中的每一個點上循環執行'FillEllipse'。 – Saragis
@Saragis我不熟悉點對象的列表,我不明白當我試圖搜索它。你可以幫我嗎?非常感謝你 –
我在答案中增加了一個例子,請檢查一下 – Saragis