【发布时间】:2015-10-25 11:42:40
【问题描述】:
我想在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 a.AREA_NO=@Anum 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 我不熟悉点对象列表,我不知道当我尝试搜索它时如何。你能帮助我吗?非常感谢
-
我在答案中添加了一个示例,请查看