[C #] image attributes in picturebox

Source: Internet
Author: User
There are three methods:
Method 1: (this method is stupid)
Hide several pictureboxes on the page that need to be changed, such as the following picfrom
Define the method for changing the image first:
System. Resources. ResourceManager resources = new system. Resources. ResourceManager (typeof (form1 ));
Then you can change it (for example, you need to change the picto image to the picfrom image)
This. picto. Image = (system. Drawing. Image) (resources. GetObject ("picfrom. Image ")));
Second:
Use Filestream Object:
Dim FS as system. Io. filestream
'Specify a valid picture file path on your computer.
FS = new system. Io. filestream ("C: \ winnt \ WEB \ wallpaper \ fly away.jpg ",
Io. filemode. Open, Io. fileaccess. Read)
Picturebox1.image = system. Drawing. image. fromstream (FS)
FS. Close ()

Third (I think it is better)
 
Use the image. fromfile method to load an image in the picturebox control.ProgramLocked.

When the application is running, the image file remains locked. Even if the image attribute is set to nothing at runtime, the image file is locked.

Picturebox1.image = image. fromfile ("C: \ winnt \ WEB \ wallpaper \ fly away.jpg ")

From:
Http://www.cnblogs.com/black263/archive/2008/01/12/1036021.html

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.