문제

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.

도움이 되었습니까?

해결책

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

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top