PictureBox Control for VB.net

Source: Internet
Author: User

PictureBox (picture box) controls are used to display graphics and can serve as containers for other controls. The icon for the PictureBox control in the Toolbox is as shown in the figure:

1. Supported graphic formats
The PictureBox control can display picture files in any of the following formats: bitmaps, icons, metafile, enhanced metafile, JPEG, or GIF files.
2. Load the graphic into the picture control
At design time, you can load a picture into a PictureBox control by selecting and setting the Image property from the Properties window, or you can set the Image property of the PictureBox control at run time:
Picturebox1.image=image.fromfile ("C:\Windows\Winlogo.cur")
Or
PictureBox1.Image.FromFile ("C:\Windows\Winlogo.cur")
3. Use clipboard
You can also add graphics to the PictureBox control at design time: Copy the graphic from another application and paste it into the PictureBox control. For example, you might sometimes want to add a bitmap image created by Windowspaint. Copy the image directly to the Clipboard, select the PictureBox control, and then use the keyboard shortcut to CTRL + V or use the Paste command on the Edit menu.
4. Set the picture size properties
The picture size is set with the SizeMode property. By default, this property value is normal, and the graphic loaded into the picture box retains its original size, which means that if the graphic is larger than the control, the portion that is exceeded is trimmed, that is, the PictureBox control does not provide a scroll bar. To make the PictureBox control automatically resize to display the full graphic, set the SizeMode property to AutoSize. The control is automatically resized to fit the loaded graphic, and when the SizeMode property is set to StretchImage, the inserted picture is displayed in the full size of the PictureBox, and when the SizeMode property is set to CenterImage, The picture is shown in the center of the PictureBox.
The PictureBox control cannot stretch the image to fit the size of the control.
5. Use the PictureBox control as a container
You can use the PictureBox control as a container for other controls. For example, because the PictureBox control can be placed in the inner area of an MDI child form, it is often used to create a toolbar or status bar manually.
border of a 6.PictureBox control
You can change the appearance of the control by setting the PictureBox BorderStyle property, which BorderStyle a total of three property values: None, FixedSingle, and Fixed3D.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.