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)
 10000  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

Mark Devid Created New Discussion What is the use of transient keyword in java   6 seconds ago

Mayank Tripathi added new Blog Cloud Computing Concepts: PaaS   15 hours ago

priyanka kushwaha added new Article Security in ASP.NET   20 hours ago

Chris S added new Question Why Java does not support pointers?   4 days ago

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