Displaying an array of images in picturebox?

前端 未结 5 1106
北荒
北荒 2021-01-14 14:38

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:\\\\picture         


        
5条回答
  •  旧时难觅i
    2021-01-14 15:43

    The answer provided throws an object reference exception. Otherwise thanks for the example!

    for (int index = 0; index < picturebox.Length; index++)
    {
         this.Controls.Add(picturebox[index]);
         // Following three lines set the images(picture boxes) locations
    

    should be

    for (int index = 0; index < picturebox.Length; index++)
    {
        picturebox[index] = new PictureBox();
        this.Controls.Add(picturebox[index]);
        // Following three lines set the images(picture boxes) locations
    

提交回复
热议问题