Link to home
Start Free TrialLog in
Avatar of Cyber-Drugs
Cyber-DrugsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

C# - Create PictureBox via pure code

Hey guys 'n gals,

Could somebody enlighten me in how I could create a new PictureBox with pure code, please? I want to basically have the ability to create/destroy multiple picture boxes on my Form via code, rather than having to physically drag and drop them onto the Form.

Cheers!


[EDIT]

Sorry, forgot to also mention, I want to change the Picture inside the newly created PictureBox to be the Picture which is inside an existing PictureBox. So far I have tried this, but it doesn't quite work...

                System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
                myPic.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox1.Image")));
                resources.ReleaseAllResources();
                myPic.Location = new Point(pictureBox1.Left + e.X - startX, pictureBox1.Top + e.Y - startY);
ASKER CERTIFIED SOLUTION
Avatar of ksaul
ksaul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ksaul
ksaul

typo here >  pc.Image = PictureBox1.Image;  //Image from existing picturebox
Avatar of Cyber-Drugs

ASKER

That did the trick, cheers! :o)