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
anil johnPosted Sep 28, 2012, 2:29 AM
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);
}
Sivaraman DhamodaranPosted Sep 28, 2012, 2:27 AM
http://www.c-sharpcorner.com/uploadfile/6897bc/picturebox-and-progressbar-control/
The shows how do you load and display the Image.
anil johnPosted Sep 28, 2012, 1:53 AM
Sivaraman DhamodaranPosted Sep 28, 2012, 1:43 AM
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;