显示图片框列表中的图像 [英] Displaying images from a picturebox list
本文介绍了显示图片框列表中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在程序中显示一行图片.但是我有一个问题,它只显示imagelist中的第一张图像,而只显示一个image-box.
I am trying to display a line of pictures in my program. But I am having a problem, where it is only showing the first image in the imagelist and only showing one image-box.
Private Cards As New List(Of PictureBox)
Private Sub SetupCards()
For i As Integer = 0 To imglist1.Images.Count - 1
Dim PicCard As PictureBox = New PictureBox()
PicCard.Width = 100
PicCard.Height = 200
PicCard.Top = 50
PicCard.Left = 50
Me.Controls.Add(PicCard)
PicCard.Image = imglist1.Images(i)
Cards.Add(PicCard)
Next i
End Sub
推荐答案
您正在将图片框彼此叠放,这就是为什么您只看到最后一张卡片的原因.您必须为添加的每个图片框设置一个不同的Left
属性.
You're placing the picture boxes on top of each other, which is why you only see the last card. You've got to set a different Left
property for every picture box you add.
解决方案非常简单.只需将图片框的宽度加到Left
,乘以当前索引i
.
The solution is rather simple. Just add the picture box's width to Left
, multiplied by the current index i
.
PicCard.Left = 50 + PicCard.Width * i
这篇关于显示图片框列表中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文