Click here to Skip to main content
15,843,200 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hey members,
i have some conceptual problem in picturebox control...that how can i show image on picturebox,in which a picture or image file is on disk....???
plz suggest me some small code module so that i could get knowledge about the one....
Posted
Comments
Chandrakantt 6-Mar-12 1:30am    
Are you saying that picture should be dynamically taken from the disk location or can it be added to the project?
[no name] 6-Mar-12 1:34am    
no...when a user browse for a picture and then selects the file...the image should be displayed on picturebox...BUT WITH NO DATABASE CONNECTIVITY....

1 solution

You can add picture into the picture box using 2 methods.
1. When you are making the project. Picture will get inserted into the binary.

You can add image location by selecting properties of picturebox and providing path to ImageLocation property.

2. You can add picture dynamically, that is during run time. In this case picture is not inside binary, it is present at some location in the hard disk.

You can update ImageLocation property during runtime as shown below.
public Form1()
{
    InitializeComponent();
    pictureBox2.ImageLocation = @"E:\TP\Songs\AlbumArtSmall.jpg";
}
 
Share this answer
 
Comments
[no name] 6-Mar-12 1:39am    
so will i have to use 'ImageLocation' property...????
coz i was using only 'Image' property...!!!
Chandrakantt 6-Mar-12 1:41am    
yes you will have to use ImgaeLocation property because the picturebox control shows picture from the path present at ImageLocation property of picture box
[no name] 6-Mar-12 1:44am    
ok..one more question plz,
the image which i selected i larger than the picturebox...so how can i resize that picture according to my picturebox size so that it fits in that completely....
Chandrakantt 6-Mar-12 1:51am    
you can use SizeMode for that.. check below code

public Form1()
{
InitializeComponent();
pictureBox2.ImageLocation = @"E:\TP\Songs\AlbumArtSmall.jpg";
pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage;
}
[no name] 6-Mar-12 1:57am    
thank you sir....i got the solution with your help.... :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900