Multiple Picture Boxes
-
I have a question(s) that I hope someone can answer. I know how to make a picture box either visible or invisible and also how to load one image into it. :confused: The questions are: Can more than one image be loaded into a picture box at one time? If so how is it done and how do you show each picture when needed? If it can't be done, what are my alternatives? I'm trying to get three pictures into the same picture box area, and show each in turn as a specific button is clicked. Thank you for any help or suggestions that are forth coming. :-D
-
I have a question(s) that I hope someone can answer. I know how to make a picture box either visible or invisible and also how to load one image into it. :confused: The questions are: Can more than one image be loaded into a picture box at one time? If so how is it done and how do you show each picture when needed? If it can't be done, what are my alternatives? I'm trying to get three pictures into the same picture box area, and show each in turn as a specific button is clicked. Thank you for any help or suggestions that are forth coming. :-D
Nope, you can't. Luckily, you have the ability to define variables ;P Declare and initialize three
Image
s and set thePictureBox
'sImage
property to the appropriate one when you need to.
Try code model generation tools at BoneSoft.com.
-
I have a question(s) that I hope someone can answer. I know how to make a picture box either visible or invisible and also how to load one image into it. :confused: The questions are: Can more than one image be loaded into a picture box at one time? If so how is it done and how do you show each picture when needed? If it can't be done, what are my alternatives? I'm trying to get three pictures into the same picture box area, and show each in turn as a specific button is clicked. Thank you for any help or suggestions that are forth coming. :-D
Use Imagelist control.
Regards, Arun Kumar.A
-
Use Imagelist control.
Regards, Arun Kumar.A
ImageList supports only specific number of colors and sizes which cause too many headaches. just create a List or Collection or Image[] myImageList = new Image[] {img1, img2, img3}; And then in a loop, Button.Click event or Timer.Tick event use this code: protected void UpdateImage(Image newImage) { //un-comment below lines if you are reading images from disk to prevent memory leaks //if(myPictureBox.Image != null) //{ // myPictureBox.Image.Dispose(); // myPictureBox.Image = null; //} myPictureBox.Image = newImage; } OR protected void UpdateImage(IList myImageList, int newIndex) { myPictureBox.Image = myImageList[newIndex]; } Hope this helps...