Reputation: 1067
I am not sure what is my mistake but i am telling you it works before. I want to change the picture in picture box based on the user's choice.
The 1st picture i put is in the picture control box. which i just put the picture without doing the codes. then, when the system received the value that user chose, the picture will change to the 2nd image.
Code:
if (fheadValue == 101)
{
Bitmap abc = (Bitmap)System.Drawing.Bitmap.FromFile
("C:\\Users\\HDAdmin\\Pictures\\humanbody\\MALE123\\images\\malebothandroid_01");
pictureBox1.Image = abc;
}
Before this, i only using this code and it does change to the second picture. but now, its not working. I don't know what is wrong with my code.
then i tried using this code.
pictureBox1.Image = Image.FromFile("C:\\Users\\HDAdmin\\Pictures\\humanbody\\MALE123\\images\\malebothandroid_01");
But still, its not working. guys, please help me with this. it does work with the previous project but when i am applying the same method to the new project, it wont work. is there any careless mistake i made without noticing it..??
Upvotes: 1
Views: 1499
Reputation: 3260
Just noticed, you haven't set the file extension of the image. you should add an extension. whether it's bmp,png,jpg..
Edit: Also call pictureBox1.Invalidate()
Edit2: As for the comments, there's no need to call Invalidate().
Upvotes: 3