bilalo

how can I change a picture in the Report header of a Crystal Reports
for Visual Studio 2005 from the run time in Microsoft Visual C# 2005


Re: Crystal Reports for Visual Studio change picture in crystal report

boban.s

Depends on where is the picture. If it's storred in Database as binary then it will work automaticaly, CR will treat that dataset column as BLOB object. If the image is in file then you should add it to your dataset:

FileStream fs = new FileStream(imageFilePath, FileMode.Open);

BinaryReader br = new BinaryReader(fs);

ds.myTableRow row = ds.myTableRow.NewmyTableRow();

row.PictureColumn = br.ReadBytes((int)br.BaseStream.Length);

ds.myTableRow.Rows.Add(row);

This is the code when you want to read the image from file, and you need to add to your dataset. Column can be binary or base64binary.

But this is usefull when you want to change the image durring runtime. I don't know your application scenario, but i use subreports for this purpose. When i need to change the image for other company instalation, then i just change the subreport image and all report are using the subreport with new image.






Re: Crystal Reports for Visual Studio change picture in crystal report

bilalo

Thank you for your quick answer.

i use a code like this

pictureBox1.Load("c:\\home.net\\My Pictures\\Blue hills.jpg");

to get a picture in my form , and i want to display this picture
in my report header

Many thanks again!






Re: Crystal Reports for Visual Studio change picture in crystal report

bilalo

hi again

can you tell me more about subreports , i think it was a good idea to change my picture in the report header at run time

tanks






Re: Crystal Reports for Visual Studio change picture in crystal report

boban.s

It all depends on your scenario. For me that is realy usefull. I have for example 100 reports with company logo and address information. All reports have included the subreport for header and subreport for footer report. In subreport header, i have included some logo, address phones, etc. So when i need to install the softwer to other company, or somthing about this company is changed, logo rarely but phone address or they just want to change the header design, then just changing the subreports it is enough. I will manually change the picture, change some other things and everything is ok.




Re: Crystal Reports for Visual Studio change picture in crystal report

bilalo

I included the subreport on the header of the MainReport from an existing report named ReportLogo

when I make change on the ReportLogo ( change the picture ,.. ) the MainReport display the old Value off

ReportLogo , I think when I need to change the Logo I need to edit the MainReport at design time and reimport

the ReportLogo again !!

If you ask about my senario it's simply I want make change in a picture in my report from the program

i can read a path of an image or store the path in data but i want to change the path of a picture in report

tank's