PictureBox (pic)

PictureBox - Allows you to display a graphic or picture.

Setting the SizeMode to "StretchImage" before you open a graphic causes Visual Studio to resize the graphic to exact dimensions of the picture box.




Examples


Useful Code

Displaying an image from a file.

picPictureBox.Image = System.Drawing.Image.FromFile("C:\Temp\testing.jpg") 
picPictureBox.Image = ProjectName.Properties.Resources.FileName
picPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
picPictureBox.Load("C:\Temp\testing.jpg")

Properties

BorderStyle Indicates the border style for the control.
ErrorImage Gets or sets the image to display when an error occurs during the image-loading process or if the image load is canceled.
Image Gets or sets the image that is displayed by PictureBox.
ImageLocation Gets or sets the path or URL for the image to display in the PictureBox.
InitialImage Gets or sets the image displayed in the PictureBox control when the main image is loading.
SizeMode Indicates how the image is displayed.
Text Overridden. Gets or sets the text of the PictureBox.
WaitOnLoad Gets or sets a value indicating whether an image is loaded synchronously.

Methods

CancelAsync Cancels an asynchronous image load.
Dispose Overloaded. Releases all resources used by the PictureBox.
Load Overloaded. Displays an image in the PictureBox.
LoadAsync Overloaded. Loads the image asynchronously.
ToString Overridden. Returns a string that represents the current PictureBox control.

Events

Leave Occurs when input focus leaves the PictureBox.
LoadCompleted Occurs when the asynchronous image-load operation is completed, been canceled, or raised an exception.
LoadProgressChanged Occurs when the progress of an asynchronous image-loading operation has changed.
SizeModeChanged Occurs when SizeMode changes.

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext