Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '------------------------------------------------------------------------------------------
- ' Notice of My Copyright and Intellectual Property Rights
- '
- ' Any intellectual property contained within the program by Joseph L. Bolen remains the
- ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
- ' publish or provide such intellectual property to any other person or entity for any
- ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
- '
- ' Copyright © 2016. All rights reserved.
- ' All trademarks remain the property of their respective owners.
- '-------------------------------------------------------------------------------------------
- ' Program Name: Load Picture Box Demo
- '
- ' Author: Joseph L. Bolen
- ' Date Created: 29 MAR 2016
- '
- ' Description: Demo to show how to load a picture box control from either
- ' My.Resources or a file.
- '
- ' Documentation is at:
- ' App's screen image is at: http://imgur.com/DjLntjp
- ' App's Visual Basic .NET code is at http://pastebin.com/PTZY6NFa
- ' Video tutorial at YouTube: http://www.youtube.com/user/bolenpresents
- '
- '-------------------------------------------------------------------------------------------
- Option Strict On
- Public Class MainForm
- ' Toggle image depending on which gender button is checked.
- Private Sub GenderButtons_CheckedChanged(sender As Object, e As EventArgs) _
- Handles MaleRadioButton.CheckedChanged, FemaleRadioButton.CheckedChanged
- If MaleRadioButton.Checked Then
- DisplayImage("MaleSihouette")
- Else
- DisplayImage("FemaleSihouette")
- End If
- End Sub
- ' Display profile sihouette in picture box.
- Private Sub DisplayImage(ByVal myImage As String)
- ' Retrieve object from resources and cast into an Image object.
- ProfilePictureBox.Image = CType(My.Resources.ResourceManager.GetObject(myImage), Image)
- End Sub
- ' Use the OpenFileDialog component to get an image.
- Private Sub GetImageButton_Click(sender As Object, e As EventArgs) _
- Handles GetImageButton.Click
- Dim ofd As New OpenFileDialog
- ofd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyPictures
- ofd.Filter = "Image Files(*.PNG;*.JPG;*.GIF*;.BMP;)|*.PNG;*.JPG;*.GIF*;.BMP;|All files (*.*)|*.*"
- If ofd.ShowDialog() = DialogResult.OK Then
- ProfilePictureBox.Load(ofd.FileName)
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment