How to new a PictureBox...??
-
My C# project Form is splitted into two parts, the left side is a tree view, the right side is a PictureBox. I want to design a function, When I click the menu button , A new PictureBox will appear, like the MDI Form does. How to new a PictureBox like that...?? or there are other better solutions...?? My original PictureBox's image must be saved, so I can't just change it's image, But if I want to new many pages, New many PictureBoxes doesn't seem to a good way...?? Please give me a hand,thanks a lot!!
-
My C# project Form is splitted into two parts, the left side is a tree view, the right side is a PictureBox. I want to design a function, When I click the menu button , A new PictureBox will appear, like the MDI Form does. How to new a PictureBox like that...?? or there are other better solutions...?? My original PictureBox's image must be saved, so I can't just change it's image, But if I want to new many pages, New many PictureBoxes doesn't seem to a good way...?? Please give me a hand,thanks a lot!!
you can save the picture and then load the new one to save: System.Drawing.Image img = pictureBox1.Image; img.Save(path, ImageFormat); to load a new one: System.Drawing.Image img2 = System.Drawing.Image.FromFile(path); pictureBox1.Image = img2;
-
you can save the picture and then load the new one to save: System.Drawing.Image img = pictureBox1.Image; img.Save(path, ImageFormat); to load a new one: System.Drawing.Image img2 = System.Drawing.Image.FromFile(path); pictureBox1.Image = img2;
A quick side note: if you only need the images to be saved during run-time (i.e. for GUI purposes) you can also crate a list or array of
System.Drawing.Image
just to keep them in memory, this could save you the usage of files, which you should afterwards clean up, might be easier. Fade (Amit BS)