Folder Browser Dialog to work in picturebox

AndrewShev05

Member
Joined
Dec 9, 2021
Messages
12
Programming Experience
Beginner
Hello, I am a bare-bones beginner with very little to no knowledge of C# programming, also new to the forum. I want to make an image viewer to load a whole folder of images and be able to scroll through them. I met a large speedbump that I cannot figure out. I am using the folder browser dialog because I need to select the whole folder. Below is the code I have, but I can't get it to work. I need the folder to be selected through the folder browser dialog and placed into the picture box. Please help.


private void loadButton_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.Load(folderBrowserDialog1.SelectedPath);
}
}
 

Attachments

  • Screenshot 2021-12-09 122119.jpg
    Screenshot 2021-12-09 122119.jpg
    17.1 KB · Views: 22
A suggestion, use a BindingSource.
  • Assign the image paths to it's DataSource when a folder is selected.
  • In CurrentChanged event handler set PictureBox.ImageLocation to Current value.
  • For navigation buttons just call BindingSource.MoveNext/MovePrevious methods.
 
Also, I see nothing in that assignment's specifications about scrollbars. Why were you saying that you needed scrollbars?

Nevermind. It was "scroll arrows" that you were talking about, not scroll bars.
 
Last edited:
Thank you for your help. I will most likely be back when I start putting it together. Had a lot of work today, don't have time to do it right now. thank you again.
 
Back
Top Bottom