WHAT'S NEW?
Loading...

How to create picture viewer in Visual Basic.Net

To create picture viewer in Visual Basic.Net is very simple with a less amount of code. In addition, any pictures in your computer can be browse and will display on your Windows Form Application. Unfortunately, it only covers how to browse picture in a local computer, once the program close, the picture you browse that display in your Windows Form will be lose. For instance, use database to stored data if you prefer the consistency so that every time to load your program, the data will remain once the program is running and it will be loaded automatically on your Forms. After working on this tutorial, the output should like the following example screenshot.

Picture Viewer in Visual Basic.Net
What we need to work with in order to create a simple picture viewer are 1 button, OpenFileDialog, and PictureBox that can be found on your toolbox controls.

Name the Button as follows:
Property       value
Name                    btnSelectPicture
Text                       Browse Picture

Name the OpenFileDialog as follows:
Property       value
Name                    ofPictureFileDialog
Filename             make it empty
Filter                     JPEG Files|*.JPG
Title                       Browse Picture

Name the PictureBox as follows:
Property       value
Name                    pictureBoxViewer
BorderStyle        FixedSingle
SizeMode            StretchImage

Note: every time you change the property value of each controls make sure you to select it.

Source code: Just simply copy and paste on your button.

Private Sub btnSelectPictures_Click(sender As System.Object, e As System.EventArgs) Handles btnSelectPictures.Click

        If ofPictureFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
            pictureBoxViewer.Image = Image.FromFile(ofPictureFileDialog.FileName)
            Me.Text = "Picture Viewer(" & ofPictureFileDialog.FileName & ") "
        End If

End Sub
Me.Text = "Picture Viewer(" & ofPictureFileDialog.FileName & ") “'show the path name of a file where the file was based in the form’s caption.

0 comments:

Post a Comment