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

OpenFileDialog Control in VB.Net

Posted by  Pushpendra Singh
on    December-13-2010 16:43 PM

VB.Net VB.Net 
Ratings:
0 Comment(s)
 10953  View(s)
Rate this:

OpenFileDialog Control in VB.Net

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

 

 

 


Recent Activities

David Miller Created New Discussion What are memory leaks in java   8 hours ago

Mayank Tripathi added new Question How to detect memory leak in Java   9 hours ago

ashish srivastava added new Blog Impact of Google Reviews in SEO   13 hours ago

Tarun Kumar added new Article iOS : SQLite Commands   15 hours ago

Don't want to miss updates? Please click the below button!