Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDisplay images with file names stored in a database
Keywordsdatabase, image, picture, filename, file name
CategoriesDatabase, Graphics
 
Bind a hidden label to the filename field. In the Data control's reposition event handler, use LoadPicture to load the picture.
 
' Load the picture for this record.
Private Sub Data1_Reposition()
    Picture1.Picture = LoadPicture( _
        App.Path & "\" & lblHiddenFileName.Caption)
    Picture1.Left = _
        (Data1.Left + Data1.Width - Picture1.Width) / 2
End Sub
 
This method is very simple and keeps the database small because the picture is stored externally. One drawback is that a picture file may be deleted without removing the corresponding database record or vice versa. To avoid some problems, you should probably use an error handler to protect the LoadPicture statement and display a default "missing" picture if the file is missing.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated