Image won't display?

hog

Senior Contributor
Joined
Mar 17, 2003
Messages
984
Location
UK
Code:
            Me.picMain.Image.FromFile(Application.StartupPath & "\photos\" & Me.cboSites.SelectedItem & "\" & Me.cboDates.SelectedItem & "\" & fiFileInfo(0).ToString)

When I run this code my picturebox wont display the file? No error occurs in my try/catch and if I messagebox the file path and name used above it appears correct?

:confused:
 
Image.FromFile() is a shared function, not an instance subroutine.
Therefore, you need to assign the result to your image.

Me.picMain.Image.FromFile(Application.StartupPath & "\photos\" & Me.cboSites.SelectedItem & "\" & Me.cboDates.SelectedItem & "\" & fiFileInfo(0).ToString)
incorrect - this is a function call with out the receipt of the return value.

Me.picMain.Image = Image.FromFile(Application.StartupPath & "\photos\" & Me.cboSites.SelectedItem & "\" & Me.cboDates.SelectedItem & "\" & fiFileInfo(0).ToString)
(They are conveniently named the same)
 
Hi, Thnx :)

Well I think it works as I believe I can see part of the image, (sky), but it means the source image is way too big for my picture box.

Is there a .NET function that resizes an image dynamically to fit pictureboxes?

Thnx
 
Mmm appears I have been down this road before. Just trolling though old posts I have found ones I stated yonks ago!!!

The mind boggles as I did not remember these topics I have covered ages ago, must be my age!
 
Back
Top