开发者

C# PictureBox.Image

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开发者_Python百科.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜