I have two buttons in my view and one picture box. I want to design a code such that the picture box displays images in a directory and after clicking either of the two buttons it displays the next image. Basically, it should wait for user to click the button.
This is the sample code. Please help me.
foreach (string file in Directory.EnumerateFiles(sourcePathImages, "*.jpg"))
{
Image loadedImage = new Bitmap(file);
if (loadedImage != null)
{
pictureBox1.Image = loadedImage;
filename.Text = filenames[counter];
label.Text = labels[counter++];
}
}
What to add in the foreach loop so that my code waits until either of the two buttons is pressed.