Question

the following is an example of test code, it maybe not be completely correct:

        for (int i = 0; i < MAXCOL; i++)
        {
            for (int j = 0; j < MAXROW; j++)
            {
                HomeArrayPicBox[i, j].Image  = Properties.Resources.scan;
            }
        }

my issue is instead of all pictureboxes displaying the same picture, i need to increment the image also. e.g. Properties.Resources.scan1, Properties.Resources.scan2 ...

please adive how best to achive this.

thank you.

Was it helpful?

Solution

You can get an object from a Resources file by name like this:

HomeArrayPicBox[i, j].Image = 
    (Image)Properties.Resources.ResourceManager.GetObject("Scan" + i);

OTHER TIPS

Make scan an array of image resources, and on each iteration, determine the correct index of that array to populate the picture box with.

You can put all image object you need in an array. The length of this array should be MAXCOL * MAXROW. I assume you have the same number of images as boxes? Than you could iterate trough this array.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top