OpenFileDialog control in VB.NET 2010
This article shows openfiledialog control in VB.NET 2010.
In this article we will learn about the file open dialog control in window application in VB.NET.
This control are used to select a file. These are the some common properties of OpenFileDialog control:
Property used to get or set file name selected in the file dialog box.
Property to used to get or set the current file name filter string which sets the choices that appear in 'Save as file type' or 'Files of type' box.
To display the dialog box to the user, call the ShowDialog() method.
click the OpenFileDialog control from toolbox it will take place below the form and take two control picture box control and button to the form.
Now, double click on the button named openfile in the form and write the following code.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.Filter = "All Files|*.*|Image Files|*.jpg;*.gif;*.png;*.bmp"
PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
To dynamically load the images use Image class with FromFile() method.
Now press Ctrl+F5 to run the application.
The below window will appear and we choose an image and than and then click on the button named openfile.the image will display on the form.
Now select an image and click the button open image will display on the picture box.we select image named two_flower from the open file.