Cyber-Drugs
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.ResourceM anager resources = new System.Resources.ResourceM anager(typ eof(Form1) );
myPic.Image = ((System.Drawing.Bitmap)(r esources.G etObject(" pictureBox 1.Image")) );
resources.ReleaseAllResour ces();
myPic.Location = new Point(pictureBox1.Left + e.X - startX, pictureBox1.Top + e.Y - startY);
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.ResourceM
myPic.Image = ((System.Drawing.Bitmap)(r
resources.ReleaseAllResour
myPic.Location = new Point(pictureBox1.Left + e.X - startX, pictureBox1.Top + e.Y - startY);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
typo here > pc.Image = PictureBox1.Image; //Image from existing picturebox
ASKER
That did the trick, cheers! :o)