在vb.net中以编程方式将多个图片框添加到表单中? [英] Adding multiple pictureboxes to a form programmatically in vb.net ?
本文介绍了在vb.net中以编程方式将多个图片框添加到表单中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须根据我的要求将pictueboxes添加到面板中.
i have to add pictueboxes in to a panel as per my requirement .
"以编程方式在vb.net 在此问题中,PictureBox是随机绘制的,但我希望以同步方式进行绘制 在此处输入代码
"Adding multiple pictureboxes to a form programmatically in vb.net " In this question PictureBox are drawn in random but i want it in a synchronous way enter code here
Dim i As String = ListBox1.Items.Count
For j As Integer = 0 To i
Dim PicBox As New PictureBox
PicBox.Width = 40
PicBox.Top = 25
PicBox.Left = j + 15
PicBox.SizeMode = PictureBoxSizeMode.StretchImage
PicBox.BorderStyle = BorderStyle.FixedSingle
Me.Panel1.Controls.Add(PicBox)
Next
我要使用自动检查i值的计数器?
i want to use counter which automatically check the value of i ?
有什么想法或建议吗?
Any idea or suggestion ?
谢谢
推荐答案
这样的事情如何?
Private Sub PicBoxTestButton_Click(sender As System.Object, e As System.EventArgs) Handles PicBoxTestButton.Click
Try
Dim numberOfPics As Integer = ListBox1.Items.Count
Dim lastLeft As Integer = 15
Const spacer As Integer = 5
For parser As Integer = 0 To numberOfPics
Dim PicBox As New PictureBox
PicBox.Width = 40
PicBox.Top = 25
PicBox.Left = lastLeft
lastLeft = PicBox.Width + PicBox.Left + spacer
PicBox.SizeMode = PictureBoxSizeMode.StretchImage
PicBox.BorderStyle = BorderStyle.FixedSingle
Me.Panel2.Controls.Add(PicBox)
Next
Catch ex As Exception
MessageBox.Show(String.Concat("An error occurred: ", ex.Message))
End Try
End Sub
这篇关于在vb.net中以编程方式将多个图片框添加到表单中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文