Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bind Picturebox to database

Status
Not open for further replies.

thedman00

Programmer
Jun 11, 2003
46
AT
I would like to bind a picturebox to a field in the database that is storing the name of an image file.
 
By name, do you mean the path to the image? I can't see how just "MyPicture.jpg" would work.

If you are using the whole path, then for "data-binding", you would need to create a custom class an inherit from PictureBox. The image property of a PictureBox takes a System.Drawing.Image. But you have a string object from your database.

So create the new class, add an "ImagePath" property, and in the setter of that, set the Image property to an Image.FromFile("abc..."). Then, you can use DataBindings.Add("ImagePath", DataObject)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top