2013-11-21 81 views
0

我需要你們的幫助,我使用此代碼生成一個TabControl多個選項卡每個都包含有不同的JPG圖片的圖片框:C#運行時生成的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。我如何才能訪問選定選項卡上的圖片框?

感謝

回答

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]); 

         } 
+0

謝謝,我想到了某種陣列能夠解決我的問題。我仍然只是初學者... – user3016036