i am getting an error on executing the below code,plz help me to rectify this
error:Cannot implicitly convert type string to system.drawing.image
private void button2_Click(object sender, EventArgs e)
{
frmPreview frmPreviewObj = new frmPreview();
frmPreviewObj.Show();
//Bitmap image = new Bitmap(fname, true);
Image img = fname;
frmPreviewObj.pictureBox1.Image = img;
}
Loading

Sivaraman DhamodaranRank #40 · 34.5K reputationPosted Sep 27, 2012, 9:43 PM EDT
fname is a string data type.
img is a system.drawing.image type
You cannot directly convert a image to string.
The Line is the bug:
Image img = fname;
anil john153 reputationPosted Sep 27, 2012, 9:53 PM EDT
Sivaraman DhamodaranRank #40 · 34.5K reputationPosted Sep 27, 2012, 10:27 PM EDT
http://www.c-sharpcorner.com/uploadfile/6897bc/picturebox-and-progressbar-control/
The shows how do you load and display the Image.
anil john153 reputationPosted Sep 27, 2012, 10:29 PM EDT
private void button2_Click(object sender, EventArgs e)
{
frmPreview frmPreviewObj = new frmPreview();
frmPreviewObj.setFilename(fname);
frmPreviewObj.Show();
frmPreviewObj.Location = new Point(0,50);
}
write this property in second form:
public void setFilename(string sFile)
{
pictureBox1.Image = Image.FromFile(sFile);
}