显示图像在PictureBox的阵列? [英] Displaying an array of images in picturebox?

查看:120
本文介绍了显示图像在PictureBox的阵列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的Visual C#我想在一个图片框来显示图像阵列

下面是我的code:

 的String [] =名单Directory.GetFiles(@C:\\\\图片,* .JPG);
图片[] =影像新的图像[5];
对于(INT指数= 0;指数小于5;指数++){
    //这里是IM STUCKED WITH
    [指数] = Image.FromFile(名单[指数])图片框;
}


解决方案

您必须所有的图像绘制到一张图像中单个图片框显示它们

这是有点复杂,您可以使用多发pictureboxes

在以下code它们是根据需要动态创建的:

  //对于设置的所有图像,确认知名度
    this.AutoScroll = TRUE;    字符串[] =名单Directory.GetFiles(@C:\\图片,* .JPG);
    图片框[] =图片框PictureBox的新[List.length的数字]
    INT Y = 0;
    对于(INT指数= 0;指数 - LT; picturebox.Length;指数++)
    {
        this.Controls.Add(图片框[指数]);
        //下面三行设置图像(图片框)的位置
        如果(索引%3 == 0)
            Y = Y + 150;每行// 3张图片,第一张图像将在(20,150)
        图片框[指数] .Location =新的点(指数* 120 + 20,Y);        图片框[指数] .Size =新的大小(100,120);
        图片框[指数] =图像配Image.FromFile(名单[指数]);
    }

I'm very new to visual C# I want to display an array of images in a picture box

Here's my code:

string[] list = Directory.GetFiles(@"C:\\pictures", "*.jpg");
Image[] images = new Image[5];
for (int index = 0; index < 5; index++)

{
    //HERE IS WHERE IM STUCKED WITH
    picturebox[index] = Image.FromFile(list[index]);
}

解决方案

You have to draw all image to one image for displaying them in single picturebox

That is bit complex you can use mutiple pictureboxes

In following code they are created dynamically according to need:

    // For confirm visibility of all images set 
    this.AutoScroll = true;

    string[] list = Directory.GetFiles(@"C:\pictures", "*.jpg");
    PictureBox[] picturebox= new PictureBox[list.Length];
    int y = 0;
    for (int index = 0; index < picturebox.Length; index++)
    {
        this.Controls.Add(picturebox[index]);
        // Following three lines set the images(picture boxes) locations
        if(index % 3 == 0)
            y = y + 150; // 3 images per rows, first image will be at (20,150)
        picturebox[index].Location=new Point(index * 120 + 20, y);

        picturebox[index ].Size = new Size(100,120);
        picturebox[index].Image = Image.FromFile(list[index]);
    }

这篇关于显示图像在PictureBox的阵列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆