如何在c#中获取从url到picturebox的所有图像



我想在c#中的url中的picturebox中显示所有图像。通过语法说出你的建议。

只需在运行时在表单加载时创建图片框即可。在每个周期之后,你只需要增加x和y的值

  private void Form1_Load(object sender, EventArgs e)
    {
        int x = 10, y = 10;
        string[] file = System.IO.Directory.GetFiles(@"C:UsersPublicPicturesSample Pictures",             "*.jpg");
        PictureBox[] pb = new PictureBox[file.Length];
        for (int i = 0; i < file.Length; i++)
        {
            pb[i] = new PictureBox();
            pb[i].Size = new System.Drawing.Size(100,100);
            pb[i].ImageLocation = file[i];
            pb[i].Location = new Point(x, y);
            this.Controls.Add(pb[i]);
            x += 100;
            if (i == 5)
            {
                 x = 10;
                 y += 120;
            }
        }
    }

提示:-从检查PictureBox.Load(字符串URL)方法开始

将ImageLocation设置为指定的URL并显示图像指示。

最新更新