Hello Friends,
I am Trying to add the picturebox dynamically in my C# win. form. it is bing loded but when i am trying to get picturebox image ie. PictureBox.Image then it is giving me null value. Suppose i have 20 picturebox then starting 2-3 Picturebox.Image is not null but rest of are null...
My code
private void button2_Click(object sender, EventArgs e)
{
if (folderpath.ShowDialog() == DialogResult.OK)
{
string path = folderpath.SelectedPath;
DirectoryInfo di = new DirectoryInfo(path);
FileInfo[] Images = di.GetFiles("*.jpg");
foreach (var img in Images)
{
PictureBox picture = new PictureBox
{
Name = "pictureBox" + i,
Size = new Size(316, 320),
Location = new Point(i * 316, 1),
SizeMode = PictureBoxSizeMode.AutoSize
};
if (img.Name.Substring(0, 5) == "Errod")
{
picture.ImageLocation = img.FullName;
ErrodImg.Add(picture);
ErrodImgpanel.Controls.Add(picture);
}
else
{
picture.ImageLocation = img.FullName;
OriginalImg.Add(picture);
OriginalImgpanel.Controls.Add(picture);
}
i++;
}
}
}
please help me out for this problem
thanks in Advance.