Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I set the image property at run time?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Titre:
How can I set the image property at run time?
Divers
Thread ID:
00976594
Message ID:
00976594
Vues:
38
How can I set the image property of a picturebox object at run time?
I have added to images (jpg) to my solution both with build action Embedded Resource, and I want to switch at run time which image is displayed. I can not use the ImageList because the image size exceeds 256x256 and is not the same for both pictures. (I might want to include more pictures in the future).

I also know that I can use the following code:
this.myPictureBox.Image = new Bitmap("C:\\myfolder\\myImage.jpg");
but if I use that code there better be an image at that location and that is not what I want. I want to embedd the image in the exe and then populate the image property of the picture box with the embedded images at runtime.

I thought a little more about this problem and I think I want to create an array of bitmaps and then load all the images into the bitmap array then I can use the following code to change the picturebox image property at runtime:
private void ChangeImage(int ImgIndex)
{
  this.myPictureBox.Image = this.myBitmapArray[ImgIndex];
}
Well the problem still remains to find a way to load an image into a bitmap object. It is very easy to do if I specify the path and the filename but again that is not something I want to do.

I did find some information using the System.Reflection.Assembly class, but I could not quite figure out how to load the resource that is embedded.

Any assistance would be greatly appreciated.

Sincerely,
Einar
Semper ubi sub ubi.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform