PictureBox Control

Submitted by: 

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.


Comments

Its a nice piece but want to know if thats all the codes.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.