【发布时间】:2016-05-13 14:36:47
【问题描述】:
我在 Visual Studio/windows 窗体应用程序中有一个面板。但我无法使用代码在其上添加图片框。如果我在没有面板的情况下工作,但我需要它。MyCodes:
PictureBox[] pipe = new PictureBox[3];
private void Form1_Load(object sender, EventArgs e)
{
CreatePipes(1);}
private void CreatetopPipes(int Number)
{
for (int i = 0; i <= Number; i++)
{
PictureBox temp = new PictureBox();
this.Controls.Add(temp);
temp.Width = 50;
temp.Height = 350;
temp.BorderStyle = BorderStyle.FixedSingle;
temp.BackColor = Color.Red;
temp.Top = 30;
temp.Left = 300;
topPipe[i] = temp;
topPipe[i].Visible = true;
}
}
【问题讨论】:
-
this- 是Form。请改用您的面板。 -
并且不要将它们全部堆叠在同一个位置!
标签: c# winforms panel picturebox