G
Guest
I created a number of pictureboxes in a panel, and want to draw lines in
those pictureboxes but I cannot. Please see the following code and make
corrections.
Thanks.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Panel1.AutoScroll = True
Panel1.Width = 200
Panel1.Height = 200
Dim max As Integer = 8
Dim p As PictureBox
Dim i As Integer
For i = 0 To max
p = New PictureBox
p.BorderStyle = BorderStyle.FixedSingle
p.BackColor = Color.FromArgb(CLng(-1))
p.Top = i * (Panel1.Height - 30) + i * 10 + 10
p.Left = 10
p.Height = Panel1.Height - 32
p.Width = Panel1.Width - 32
Dim gr As Graphics = p.CreateGraphics
gr.DrawLine(Pens.Green, 0, 0, 30, 30)
Panel1.Controls.Add(p)
Next
'Panel1.Controls.Add(p)
'Panel1.Controls.Item(i).Top = i * (Panel1.Height - 30) + i * 10 + 10
'Panel1.Controls.Item(i).Left = 10
'Panel1.Controls.Item(i).Height = Panel1.Height - 32
'Panel1.Controls.Item(i).Width = Panel1.Width - 32
'Dim gr As Graphics = Panel1.Controls.Item(i).CreateGraphics
'gr.DrawLine(Pens.Green, 0, 0, 30, 30)
End Sub
those pictureboxes but I cannot. Please see the following code and make
corrections.
Thanks.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Panel1.AutoScroll = True
Panel1.Width = 200
Panel1.Height = 200
Dim max As Integer = 8
Dim p As PictureBox
Dim i As Integer
For i = 0 To max
p = New PictureBox
p.BorderStyle = BorderStyle.FixedSingle
p.BackColor = Color.FromArgb(CLng(-1))
p.Top = i * (Panel1.Height - 30) + i * 10 + 10
p.Left = 10
p.Height = Panel1.Height - 32
p.Width = Panel1.Width - 32
Dim gr As Graphics = p.CreateGraphics
gr.DrawLine(Pens.Green, 0, 0, 30, 30)
Panel1.Controls.Add(p)
Next
'Panel1.Controls.Add(p)
'Panel1.Controls.Item(i).Top = i * (Panel1.Height - 30) + i * 10 + 10
'Panel1.Controls.Item(i).Left = 10
'Panel1.Controls.Item(i).Height = Panel1.Height - 32
'Panel1.Controls.Item(i).Width = Panel1.Width - 32
'Dim gr As Graphics = Panel1.Controls.Item(i).CreateGraphics
'gr.DrawLine(Pens.Green, 0, 0, 30, 30)
End Sub