Im using:

OpenFileDialog1.Title = "Select your image"
        OpenFileDialog1.InitialDirectory = "C:"

        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then

            PictureBox1.Image = New System.Drawing.Bitmap(OpenFileDialog1.FileName)

        End If

for browsing an image but i want to create a filetype so i have to use OpenFileDialog1.Filter but it wont work.
I've used:

OpenFileDialog1.Filter = "Foto's (*.jpg,*.bmp,*.jpeg,*.png,*.wmf,*.gif)|*.jpg|*.bmp|*.jpeg|*.png|*.wmf|*.gif"

How can i make it work?

i figured it out i have to use

OpenFileDialog1.Filter = "Foto's (*.jpg,*.bmp,*.jpeg,*.png,*.wmf,*.gif)|*.jpg;*.bmp;*.jpeg;*.png;*.wmf;*.gif"

How can i make the picture that the user choose fit in the picturebox????

(picture width must be 100% picturebox width)


Edit: I have to use PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

hi, i'm reading your thread but i wanna to know did you use this code in web pages ro windows application?? because i'm serching for code to upload image in my web project and when i see your code i'm trying to find the controld you mention such as openfiledialog and picture box but didn't find them in the toolbox.by the way i'm using visual studio 2005.:) :-/

hi, i'm reading your thread but i wanna to know did you use this code in web pages ro windows application?? because i'm serching for code to upload image in my web project and when i see your code i'm trying to find the controld you mention such as openfiledialog and picture box but didn't find them in the toolbox.by the way i'm using visual studio 2005.:) :-/

Private Sub ButFoto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butFoto.Click

OpenFileDialog1.Title = "Selecteer een foto"
OpenFileDialog1.InitialDirectory = "C:"
OpenFileDialog1.Filter = "Foto's (*.jpg,*.bmp,*.jpeg,*.png,*.wmf,*.gif)|*.jpg;*.bmp;*.jpeg;*.png;*.wmf;*.gif"

If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then

Try
pbFoto.Image = New System.Drawing.Bitmap(OpenFileDialog1.FileName)
pbFoto.SizeMode = PictureBoxSizeMode.Zoom
Catch ex As Exception
MessageBox.Show("U heeft een incorrecte foto gekozen.", "Incorrect", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try

End If

End Sub

The complete code

U can find OpenFileDialog and Picturebox under All Windows Forms in the Toolbox from vb2005 express edition

Edit: Im using VB 2005 and i didnt use visual studio so u have to search by ure self ore someone else can reply for u

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.