get the name of the backgroundimage

KriZa

Member
Joined
Jun 22, 2007
Messages
21
Programming Experience
3-5
Hi,

I got a PictureBox Control with a BackgroundImage. Related to the active Image I will show the next image by manipulating the name-string. But how to get the name of the actual shown image? All my images stored under ressources.
Following wont work:
PB.BackgroundImage.ToString
it will give: "System.Drawing.Bitmap"

thanks
 
You can only get the image location from Picturebox if it was loaded with ImageLocation property, else you have to store information yourself elsewhere, for example using the Tag property. The reason for this is that images don't have a file location property, they may not even be loaded from a file at all, but for example loaded from a resource or other stream or generated at runtime with Graphics functionality.
 
thanks for your answer!

the workaround with the tag property I progged in meantime. thought there is a better solution - but the tag property is a nice way.

greets!
 
Back
Top