我有我写的这段代码,但是当我左键单击表单时使用了这段代码,但不是随机数的圆圈。我想知道当我单击一个按钮时,如何调整它以在表单上绘制 5-10 个随机颜色的随机圆圈,但它必须使用循环。谢谢!!
Private Sub CirclePainterForm_MouseDown(ByVal sender As _
Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles MyBase.MouseDown
Dim graphicsObject As Graphics = CreateGraphics()
Dim randomObject As Random = New Random
Dim diameter As Integer = randomObject.Next(5, 200)
If e.Button = Windows.Forms.MouseButtons.Left Then
graphicsObject.FillEllipse(New SolidBrush(RandomColor()), e.X, e.Y, _
diameter, diameter)
graphicsObject.FillEllipse(New SolidBrush(RandomColor()), e.X + 250, e.Y, _
diameter + 50, diameter + 50)
graphicsObject.FillEllipse(New SolidBrush(RandomColor()), e.X + 500, e.Y, _
diameter + 75, diameter + 75)
graphicsObject.FillEllipse(New SolidBrush(RandomColor()), e.X + 750, e.Y, _
diameter + 100, diameter + 100)
graphicsObject.FillEllipse(New SolidBrush(RandomColor()), e.X + 1000, e.Y, _
diameter + 125, diameter + 125)