• June 13, 2021

PHSARIT

Bring Technology Ideas with you

 Display image in Picturebox

Picture box is a control in Visual Basic that is used to display images from file in your local machine or even from database. This tutorial is working brows image from your local machine to display in your picture box control using VB.net Programming as the image below:

    In your project Form, please take a look to Tool Box for the control name PictureBox then drop in your form and also one Button as image

      In the top on your public class, please imports some libraries

      Imports System.IO
      Imports System.Drawing.Image

        Then drag and drop other control call OpenFile Dialogue to your Form after that use this code on the Button Event On Click:

        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles bntBrows.Click
                Dim Img As New OpenFileDialog
                Img.Filter = "Profile Photo|*.jpg;*.png;*.bmp"
                If Img.ShowDialog = DialogResult.OK Then
                    PictureBox1.Image = Image.FromFile(Img.FileName)
                    PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
                End If
            End Sub

        The result:

          Related post