Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Several Windows Forms controls can display images. These images can be icons that clarify the purpose of the control, such as a diskette icon on a button denoting the Save command. Alternatively, the icons can be background images to give the control the appearance and behavior you want.
In Visual Studio, use the Visual Designer to display an image.
Open the Visual Designer of the form containing the control to change.
Select the control.
In the Properties pane, select the Image or BackgroundImage property of the control.
Select the ellipsis (
) to display the Select Resource dialog box and then select the image you want to display.
Set the control's Image
or BackgroundImage
property to an object of type Image. Generally, you'll load the image from a file by using the FromFile method.
In the following code example, the path set for the location of the image is the My Pictures folder. Most computers running the Windows operating system include this directory. This also enables users with minimal system access levels to run the application safely. The following code example requires that you already have a form with a PictureBox control added.
// Replace the image named below with your own icon.
// Note the escape character used (@) when specifying the path.
pictureBox1.Image = Image.FromFile
(System.Environment.GetFolderPath
(System.Environment.SpecialFolder.MyPictures)
+ @"\Image.gif");
' Replace the image named below with your own icon.
PictureBox1.Image = Image.FromFile _
(System.Environment.GetFolderPath _
(System.Environment.SpecialFolder.MyPictures) _
& "\Image.gif")
.NET Desktop feedback feedback
.NET Desktop feedback is an open source project. Select a link to provide feedback:
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Use and understand Controls in a canvas app in Power Apps - Training
Controls help create a better experience for the user and collect the appropriate data. This module helps you understand and use Controls.