Click here to Skip to main content
15,912,837 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello everyone,
Is there a method of adding premade picturboxes into array.
I have used pictureboxes in my project, now i want to put them in an array.

Thanks in advance:D
z3ngew
Posted

1 solution

Hi, solution seems relatively straightforward, with informations you gave us :

C#
PictureBox myPictureBox = new PictureBox();
// Set desired properties of the PictureBox
List<picturebox> boxes = new List<picturebox>();
boxes.Add(myPictureBox);

//Finally
PictureBox[] pictureBoxArray = boxes.ToArray();
</picturebox></picturebox>
 
Share this answer
 
Comments
z3ngew 16-Jan-13 8:00am    
Thank you very much,
but is there a method i can select all the pictureboxes in a form and then add some of them in an array, maybe from the Form designer

Thanks in advance
z3ngew
phil.o 16-Jan-13 8:10am    
You then have to iterate through the Controls collection of your Form, see if it is a PictureBox, and add it to the list if so.
This could be a little more complicated if your PictureBoxes are located inside container control(s). But the idea is to iterate through the Controls collection of the Form.
z3ngew 16-Jan-13 8:16am    
Thank you,
z3ngew

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900