i'm experiencing problem program. want create photo gallery girlfriend can install on computer. want import images folder on form load , display them in picturebox.
when load form big red 'x' fills box. looks drawing.bitmap errorimage. problem? appreciated. thank you.
private sub pigge_gallary_load(sender object, e eventargs) handles mybase.load dim directory new io.directoryinfo("c:\pics\bears") if directory.exists dim jpgfiles() io.fileinfo = directory.getfiles("*.jpg") each jpgfile io.fileinfo in jpgfiles if jpgfile.exists dim image = drawing.image.fromfile(jpgfile.fullname) using image picpig.image = image end using end if next end if end sub
once exit using
block, you're losing image reference.
try changing
picpig.image = image
to
picpig.image = image.clone
or set image file:
picpig.image = drawing.image.fromfile(jpgfile.fullname)
also, because you're doing in loop, it's going replace picturebox image loops. when finishes loop, picturebox displaying last image.
Comments
Post a Comment