我需要你的帮助,我正在使用这段代码在TabControl中生成多个标签,每个标签包含一个带有不同JPG图片的PictureBox:
foreach (var file in d.GetFiles("*.jpg"))
{
string title = file.Name + (TCFichiers.TabCount + 1).ToString();
TabPage myTabPage = new TabPage(title);
TCFichiers.TabPages.Add(myTabPage);
PictureBox i = new PictureBox();
myTabPage.Controls.Add(i);
}
我想使用一个按钮来旋转所选标签的PictureBox中的图像,但我无法弄清楚如何访问正确的PictureBox。如何只访问所选标签上的图片框?
由于
答案 0 :(得分:0)
请参阅this:
PictureBox[] Shapes = new PictureBox[Num_Picbox];
for (int i = 0; i < Num_Picbox; i++)
{
Shapes[i] = new PictureBox();
Shapes[i].Name = "ItemNum_" + i.ToString();
Shapes[i].Location = new Point(label5.Left+1,label5.Top);
Shapes[i].Size = new Size(100, 100);
Shapes[i].BackColor = Color.Black;
Shapes[i].Image = (Bitmap)(e.Data.GetData(DataFormats.Bitmap));
Shapes[i].Visible = true;
this.Controls.Add(Shapes[i]);
}