画像を含むフォルダーから画像ボックスを動的に作成しようとしていますが、私のコードでは画像ボックスを 1 つしか作成できません。画像ごとに 1 つの画像ボックスを作成するにはどうすればよいですか?
これが私のコードです:
namespace LoadImagesFromFolder
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string[] images = Directory.GetFiles(@"C:\Users\Public\Pictures\Sample Pictures", "*.jpg");
foreach (string image in images)
{
pictureBox1.Image = new Bitmap(image);
}
}
}
}