The Windows Forms PictureBox control is used to display images in bitmap, GIF,icon, or JPEG formats.
You can set the Image property to the Image you want to display, either at design time or at run time. You can programmatically change the image displayed in a picture box, which is particularly useful when you use a single form to display different pieces of information.
PictureBox1.Image = Image.FromFile("C:\testImage.jpg")
The SizeMode property, which is set to values in the PictureBoxSizeMode enumeration, controls the clipping and positioning of the image in the display area.
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
There are five different PictureBoxSizeMode is available to PictureBox control.
AutoSize - Sizes the picture box to the image. CenterImage - Centers the image in the picture box. Normal - Places the upper-left corner of the image at upper left in the picture box
StretchImage - Allows you to stretch the image in code
You can change the size of the display area at run time with the ClientSize property.
pictureBox1.ClientSize = New Size(xSize, ySize)
The following VB.Net program shows how to load a picture from a file and display it in streach mode.
- Visual Studio IDE
- Windows Forms
- Label Control
- Button Control
- TextBox Control
- ComboBox Control
- ListBox Control
- Checked ListBox Control
- RadioButton Control
- CheckBox Control
- ProgressBar Control
- ScrollBars Control
- DateTimePicker Control
- Treeview Control
- ListView Control
- Menu Control
- MDI Form
- Color Dialog Box
- Font Dialog Box
- OpenFile Dialog Box
- Print Dialog Box
- KeyPress event in VB.NET
- How to create Dynamic Controls in VB.NET ?
- How do i keep a form on top of others
- Timer Control - VB.Net