Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how to read images from folder in c# windows application

Hi friends,

am working of windows application c# project.

my requirement is..,
I have two forms (Form1, Form2)

In form1 it has user data entry with textboxes and dropdownlist and submit button.
here, the user will input his data and data will be stored in Sql table.

In dropdownlist it has images type to select like happy,sad,normal

whatever the user selects image in form1...it should read from images folder and display in form2 picture box.

In form 2, I have a picture box control to display image.

Please help thanks.
Posted
Comments
BillWoodruff 31-Dec-14 4:46am    
Is this Windows Forms, or Web Forms ? The use of the word "submit" makes me think it's Web Forms.

Are pictures actually displayed (as thumbnails ?) on Form1; is only one picture displayed on Form2 ?

What have you tried so far to get the Picture selected on Form1 displayed in Form2 ?

1 solution

If the options are fixed, then don't load on demand: load the images from the disk - using Image.FromFile[^] - as part of your main form startup, and store those in Image class instances. You can then create an Image property of your second form which the first sets when the selection changes. The property then sets the PictureBox control to display the actual image.

If they aren't fixed, then the same process occurs, except the file is loaded at runtime by the main form (and copied into a different Image instance to release the file handle) before being passed to the second form instance property.

See here: Transferring information between two forms, Part 1: Parent to Child[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900