我想显示13个图片框,但是,它最后只有最后一个可见。 所以我想知道如果我做错了。显示图片框阵列
以下代码从资源文件夹中获取图像。
var testP = new PictureBox();
for (int i = 0; i < 13; i++)
{
testP.Width = 65;
testP.Height = 80;
testP.BorderStyle = BorderStyle.None;
testP.SizeMode = PictureBoxSizeMode.StretchImage;
test[i] = getImage(testP, testPTemp[i]);
}
下面的代码试图显示13位图片移动的位置。
这两个代码段应该能够执行该操作。
test = new PictureBox[13];
for (var i = 0; i < 13; i++)
{
test[i].Image = (Image)Properties.Resources.ResourceManager.GetObject("_" + testTemp[i]);
test[i].Left = 330;
test[i].Top = 500;
test[i].Location = new Point(test[i].Location.X + 0 * displayShift, test[i].Location.Y);
this.Controls.Add(test[i]);
}
这里是的getImage()
private PictureBox getImage(PictureBox pB, string i) // Get image based on the for loop number (i)
{
pB.Image = (Image)Properties.Resources.ResourceManager.GetObject("_" + i); // Get the embedded image
pB.SizeMode = PictureBoxSizeMode.StretchImage;
return pB;
}
你想达到什么目的? – Aybe
@Aybe我试图展示13 pictureBox,但它只显示我最后一个,所以我想知道如果我做错了。顺便说一句,感谢您的回复 – Edwardhk
是的,但你如何显示,水平,垂直等...解释*确切*你需要什么。 – Aybe