Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27517

VS 2010 [RESOLVED] open an image in picturebox

$
0
0
Hi folks.

I use OpenFileDialog to retrieve a filename(.jpg) to open, and save the name as a string(filename). Now I want to load this file in the picturebox, so I use "Me.Picturebox.Image = ", but I have no idea what to put on the right side of the equation. I know that fiilename should be included, but don't know the rest of the code. I've tried using code snippets, but can't get it to work. Help?

Thanks in advance.

Code:

Public Class Form1

    Private Sub PictureBox1_Click(sender As System.Object, e As System.EventArgs) Handles PictureBox1.Click
        MenuStrip1.Visible = True
    End Sub

    Private Sub NewToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles NewToolStripMenuItem.Click
        Dim filename As String
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            filename = OpenFileDialog1.FileName
            Me.PictureBox1.Image = what goes here?
        End If
    End Sub
End Class


Viewing all articles
Browse latest Browse all 27517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>