Sunday, February 12, 2012

Adding an Image

Hello:

I have an Image control on my report .

I have a Class for example :

public Class Class1

private _MyPic as System.Drawing.Image

public property MyPic as System.Drawing.Image

......

end

end

the Dataset Of My Report is Class1.

i Drop an Image from toolbar in My Report and set Source to Database and set value to =Fields!MyPic.value

befor showing the Report i Create an object from Class1 and fill MyPic and set DataSet of Report to that Object

but i see a Red X instead of Picture

please help me

thanks alot

Setting the image source = Database is correct, but you have to convert the System.Drawing.Image into the actual image data as byte array.

Here is a C# code snippet to convert an image into a byte[] using a MemoryStream:

// save image to byte[]
System.IO.MemoryStream renderedImage = new MemoryStream();
myImage.Save(renderedImage);
renderedImage.Position = 0;
return renderedImage.ToArray();

-- Robert

No comments:

Post a Comment