PictuerBox1.ImageLocation property
I want to use property ( PictuerBox1.ImageLocation) but I found that this property returns null. I don't understand how???
PictureBox pb = new PictureBox();
Image loadedImage = Image.FromFile("C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\Sample Pictures\\Winter.jpg");
pb.Height = 50;
pb.Width = 50;
pb.Image = loadedImage;
string s = pb.ImageLocation;
Master BillaPosted Sep 20, 2009, 11:05 PM
You need set image using the imgelocation other than ImageFromFile
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim frmMain As New Form3()
Dim ctrl As Control
Dim pictureboxname As String
Dim myPics As New DirectoryInfo("C:\Documents and Settings\My Documents\My Pictures")
Dim r As New Random()
Dim i As Integer = r.Next(myPics.GetFiles.Length)
Dim Pics() As FileInfo = myPics.GetFiles
If TypeOf ctrl Is PictureBox And ctrl.Name = pictureboxname Then
Dim MyPictureBox As PictureBox
MyPictureBox = ctrl
MyPictureBox.ImageLocation = Pics(i).FullName
MyPictureBox.SizeMode = PictureBoxSizeMode.StretchImage
End If
End Sub
Thank you