• September 24, 2021

PHSARIT

Bring Technology Ideas with you

 Display image in picturebox using vb.net programming

Until you have problem using your code to show image, you will find this way to work with your VB.net to show image in picture box.

Create a form design as below using: Textbox to show path of your image, One Button, and draw your picture box as the form:

    By drag the File Dialoq in your form then in your button event copy the code as below:

     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            OpenFileDialog1 = New OpenFileDialog
            OpenFileDialog1.Filter = "Picture Files (*)|*.bmp;*.gif;*.jpg"
            If OpenFileDialog1.ShowDialog = DialogResult.OK Then
                Me.TextBox1.Text = OpenFileDialog1.FileName
                PictureBox1.Image = System.Drawing.Image.FromFile(OpenFileDialog1.FileName)
                PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
            End If
        End Sub

    In your header of your form , please insert this two line code:

    Imports System.Drawing
    Imports System.IO.Path

      The result as the above

      Related post