0% found this document useful (0 votes)
42 views1 page

Openfd - Filter "Jpeg Images - .JPG - All Files - . "

To display all file types in an open file dialog box, use an asterisk as a wildcard for the file extension. After getting the file name selected by the user, it can be loaded into an image box by assigning the Image.FromFile method, passing the file name variable, to the image box's Image property.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views1 page

Openfd - Filter "Jpeg Images - .JPG - All Files - . "

To display all file types in an open file dialog box, use an asterisk as a wildcard for the file extension. After getting the file name selected by the user, it can be loaded into an image box by assigning the Image.FromFile method, passing the file name variable, to the image box's Image property.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

To display files of any type, use an asterisk symbol in place of the file extension. For example: openFD.

Filter = "JPEG Images|*.jpg|All Files|*.*";

However, we still haven't inserted a new image. To place a selected image into the picture box, you have to get the file name that the user selected. You can add a string variable to your code for this: string Chosen_File = ""; You then access the FileName property of openFD. Like this: Chosen_File = openFD.FileName; The file name will then be in the variable we've called Chosen_File. To place a new image into the picture box you have on the form, you need the Image property: pictureBox1.Image To place your chosen file into the Image property, you need this: pictureBox1.Image = Image.FromFile(Chosen_File); So after the equals sign, you can use the Image object. This has a method called FromFile( ). In between the round brackets of this method, you type the name of the image file. For us, this image file is stored in our Chosen_File variable.

You might also like