PictureBox Control

The Picturebox control is used in displaying graphics in different format like bitmap, PNG, JPEG metafile and icon format. And we can set the image property on both design time or at run time. This time, create a new visual basic project and name it as “picturebox” and drag a picturebox on the form. Here’s the following steps to display a graphic into a picture box: • Select the picturebox • Then, on the property window • Choose the image property and click the ellipse button • Then a Select resource dialog will show and it looks like as shown below • And on the Resource context, select the Local resource • Next, click Import • Then browse for a specific from your computer • And click OK button. • Then on the property window choose SizeMode • And set it into StretchImage • Finally, it will look like as shown below. This time lets add image during design time and display it at run time. And here’s the following steps. • First double click the form • And add the following code
  1. 'get the image and display to picture box based on the image location specified
  2. PictureBox1.ImageLocation = "C:\Users\Public\Pictures\SamplePictures\koala.jpg"
  3. 'set the size Mode into StretchImage
  4. PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
• Then press “F5” • And the output will now look like as shown below.


Add new comment