简体   繁体   中英

C# Runtime Generated PictureBox Control

I need your help, I'm using this code to generate multiple tabs in a TabControl each containing a PictureBox with a different JPG picture:

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

I want to use a button that will rotate the image in the PictureBox of the selected tab however I can't figure out how to get access to the right PictureBox. How can I access only the picturebox on the selected tab?

Thanks

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

                        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM