vb.net在100个picturebox控件上画同样的图,有什么简便的方法没,除了复制100遍代码
我做了一个示例,在3*4的picturebox上画圆,你可以通过该参数来达到100个圆。
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For j As Integer = 0 To 2
For i As Integer = 0 To 3
Dim nPic As New PictureBox
With nPic
.Size = New Size(100, 100)
.Location = New Point(i * 150 + 20, j * 150 + 20)
.ImageLocation = "C:\Users\Xiansr\Pictures\丝绸\20121142591274218.jpg"
.Load()
End With
Me.Controls.Add(nPic)
Dim gm As Graphics = Graphics.FromImage(CType(Me.Controls.Item(i + (j * 4)), PictureBox).Image)
gm.DrawArc(Pens.White, 25, 25, 50, 50, 0, 360)
Next
Next
End Sub