articles

Home / DeveloperSection / Articles / OpenFileDialog Control in VB.Net

OpenFileDialog Control in VB.Net

Pushpendra Singh18938 13-Dec-2010

A OpenFileDialog control is used to select a file. OpenFileDialog provide files to the user and retrieves the user's file selection back to the program

Drag and drop OpenFileDialog control from toolbox on the window Form.

OpenFileDialog Control in VB.Net

OpenFileDialog Control in VB.Net

Drag and drop PictureBox and a Button.

OpenFileDialog Control in VB.Net

Code:

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' OpenFileDialog will open
        OpenFileDialog1.ShowDialog()
        ' OpenFileDialog will open this directory
        OpenFileDialog1.InitialDirectory = "c:\Libraries\Pictures"
        'selected Image will show in the pictureBox
        PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
        ' Image.FromFile Method Creates an Image from the specified file.
End Sub

Run the project

 

OpenFileDialog Control in VB.Net

When you click select image button then file file browser window will open.

OpenFileDialog Control in VB.Net

When you select file and click open then selected file will show in the PictureBox on the Form.

OpenFileDialog Control in VB.Net

 

 

 


Updated 07-Sep-2019

Leave Comment

Comments

Liked By