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.


Drag and drop PictureBox and a Button.

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

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

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

|