Click here to Skip to main content
15,895,370 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use VS2005.
I am making a 'user control'.My control will add a picturebox when pressing a button.Picturebox will have coordinates x = picturebox final.x
Each picturebox.picture will get a path which contains images from a file.Need to create an array of image controls.Length of the array will increase after adding.
How to resize an array and initialize attribute 'picture' of the picturebox?
thank
Posted
Comments
BillWoodruff 4-Nov-11 5:58am    
Please clarify: you create a usercontrol, it has a button, you click the button ... and open up a file which may contain one or more pictures ... in what format ? ... or, is the file a text file with just a list of filepaths to pictures that you can then enumerate, and load each one into its own picture-box ?

In any case, consider using a List<PictureBox> or whatever instead of an Array.

Or maybe you are using OpenFileDialog to let the end-user select one or more pictures ?

Don't use an array - use a List<T> instead - you can treat it like an array, but it is expandable:
C#
List<Image> myImages = new List<Image>();
myImages.Add(new Image.FromFile(path));


The PictureBox does not have a Picture property - use the Image property instead.
 
Share this answer
 
Solution 1 is right d(new Image.FromFile(path))
but if you keep Picturebox it will help you more.
C#
List<PictureBox> myImages = new List<PictureBox>();
 
Share this answer
 
Comments
giatuan2011 5-Nov-11 2:37am    
I do not know how to use .Add() and set properties.Can you give me more details?thank

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