Could somebody show me how to open a Jpeg in a PictureBox by using a control button which takes you to an "Open" dialog which allows you to select the picture?
Printable View
Could somebody show me how to open a Jpeg in a PictureBox by using a control button which takes you to an "Open" dialog which allows you to select the picture?
What did you find when you researched this? And what didn't work like you expected it to?
try this:
vb Code:
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim ofd As New OpenFileDialog ofd.Filter = "Image Files|*.jpg;*.gif;*.bmp;*.png;*.jpeg|All Files|*.*" If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then picturebox1.image = New Bitmap(ofd.FileName) End If End Sub End Class
Thank You
You're quoting me out of context. I didn't have the solution. I could have come up with a copy and paste solution, but why should I, when it's clear the OP hasn't attempted anything on his own yet? I wanted to help him reach it on his own and help fix the mistakes he made by actually learning and not copy and pasting.
There's a good chance he has no idea how that code works. He only knows that it does and that's all.
99% of the other members, including the mods, I think, would agree with me. I didn't withhold the information to hinder learning, which is what that quote was getting at. I didn't provide it, so that learning would progress, but it was in the best possible way.
But, since you did decide to quote me, it's important that others understand the context of that quote. This post is where it originated and it's clearly a very different situation.
Doing the thinking for people teaches them that they don't have to think for themselves. It might solve the immediate problem but it doesn't make them a better developer. Trying and failing is an important part of the learning process. Not trying and having someone else do it for you is not learning at all. Helping someone fix the code they've already tried is far more beneficial. It might take more time and more effort, but the reward is far greater. You may think you are, but you're not really doing people any great favour by providing cut and paste solutions with no explanation and no effort on their part, assuming that their goal is to become a better developer.
guys i did not mean to start a debate here. The bottom line is someone did post the code. It does work and after looking at the code i do understand what the different parts of it do. I realize that many posters would not take any time to understand the solution they are given and simply cut and paste it so i can understand your frustrations. I have posted a few other questions since asking this one and have included code snippets that i am working with.
Again i do thank you all for your help here.
That's fine, but I just Googled and found pretty much the same thing already one the web.
http://www.google.com.au/search?q=op...ient=firefox-a
That's pretty much what weirddemon was getting at : look first, ask questions later.