C# PictureBox.Image
以下是测试代码的示例,它可能不完全正确:
for (int i = 0; i < MAXCOL; i++)
{
for (int j = 0; j < MAXROW; j++)
{
HomeArrayPicBox[i, j].Image = Properties.Resources.scan;
}
}
我的问题是不是所有图片框都显示相同的图片,我还需要增加图像。例如 Properties.Resources.scan1、Properties.Resources.scan2 ...
请说明如何最好地实现此目的。
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过名称从资源文件中获取对象,如下所示:
You can get an object from a Resources file by name like this:
扫描图像资源数组,并在每次迭代时确定该数组的正确索引以填充图片框。
Make scan an array of image resources, and on each iteration, determine the correct index of that array to populate the picture box with.
您可以将所需的所有图像对象放入一个数组中。
该数组的长度应为 MAXCOL * MAXROW。
我假设你的图像数量与盒子数量相同?
比你可以迭代这个数组。
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.