Introduction
Browsing and displaying an image in picture box tool using Windows Forms application is a very simple task. In this application, we use the following classes/controls to do the b.
- OpenFileDialog
- PictureBox
- TextBox
- Button
Main Functions
This functions simply perform the following steps,
- Open a file dialog box so that a user can select an image from his/her machine
- Browse the image
- Display selected image in a picture box on a Form
- Display image file path in text box
Here is the code,
-
- OpenFileDialog open = new OpenFileDialog();
-
- open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
- if (open.ShowDialog() == DialogResult.OK) {
-
- pictureBox1.Image = new Bitmap(open.FileName);
-
- textBox1.Text = open.FileName;
- }
What is an image filter?
Image filter is basically a filter that restrict user to select only valid image file. You can remove image filter.